Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, a;
  8. vector <int> list;
  9. vector <int> shortList;
  10. cin >> n;
  11. for(int i = 0; i < n; i++)
  12. {
  13. cin >> a;
  14. list.push_back(a);
  15. }
  16.  
  17. bool copy = false;
  18. for (auto it1 = list.begin(); it1 != list.end(); it1++)
  19. {
  20. copy = false;
  21. for (auto it2 = it1 + 1; it2 != list.end(); it2++)
  22. {
  23. if(*it1 != *it2)
  24. {
  25. copy = true;
  26. }
  27. }
  28.  
  29. if(copy)
  30. {
  31. shortList.push_back(*it1);
  32. }
  33. }
  34.  
  35. for(int i = 0; i < shortList.size(); i++)
  36. {
  37. cout << shortList[i] << " ";
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement