fork download
  1. #include <iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. int main() {
  6. list<int> lst;
  7. int x;
  8. while(cin >> x){
  9. if(x == -1) break;
  10. lst.push_back(x);
  11. }
  12.  
  13. lst.sort();
  14. lst.unique();
  15.  
  16. for(auto x : lst) cout << x << " ";
  17. cout << "\n";
  18. }
Success #stdin #stdout 0.01s 5280KB
stdin
1 2 3 4 5 3 -1
stdout
1 2 3 4 5