Created
November 19, 2012 15:14
-
-
Save Rhomboid/4111209 to your computer and use it in GitHub Desktop.
Remove duplicates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iterator> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<int> vec((istream_iterator<int>(cin)), istream_iterator<int>()); | |
copy(vec.begin(), unique(vec.begin(), vec.end()), ostream_iterator<int>(cout, "\n")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
2 | |
2 | |
2 | |
3 | |
4 | |
4 | |
5 | |
6 | |
6 | |
6 | |
6 | |
7 | |
7 | |
8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ g++ -Wall -Wextra -Werror -pedantic -O2 20121119.cpp -o 20121119 | |
$ ./20121119 <input.txt | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment