123456789101112131415161718192021222324252627282930313233343536
#include<iostream> #include <vector> using namespace std; int main() { vector<int> A; int input; int x; vector<int> C; while(cin >>input) { cin >> input; A.push_back(input); } for(int i=0; i < A.size(); i++) { C.push_back(A.back()); //check if C[i] is already in the vector: //C.pop_back; //else: //continue } } .
1234
// http://en.cppreference.com/w/cpp/algorithm/sort std::sort( vec.begin(), vec.end() ) ; // http://en.cppreference.com/w/cpp/algorithm/unique vec.erase( std::unique( vec.begin(), vec.end() ), vec.end() ) ;
123
// http://en.cppreference.com/w/cpp/container/unordered_set std::unordered_set<int> set( vec.begin(), vec.end() ) ; vec = { set.begin(), set.end() } ;