fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. list<int> lst;
  6. int x;
  7.  
  8. while (cin >> x && x != -1) {
  9. lst.push_back(x);
  10. }
  11.  
  12. lst.sort();
  13. lst.unique();
  14.  
  15. for (int val : lst) {
  16. cout << val << " ";
  17. }
  18. cout << "\n";
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5292KB
stdin
1 2 3 4 5 3 -1
stdout
1 2 3 4 5