Skip to content

Instantly share code, notes, and snippets.

@Rhomboid
Created November 19, 2012 15:14
Show Gist options
  • Save Rhomboid/4111209 to your computer and use it in GitHub Desktop.
Save Rhomboid/4111209 to your computer and use it in GitHub Desktop.
Remove duplicates
#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"));
}
1
2
2
2
3
4
4
5
6
6
6
6
7
7
8
$ 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