Guest User

Untitled

a guest
Feb 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // s2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <vector>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. bool exist(int a, const vector<int>& v)
  11. {
  12. for(int i=0; i<v.size(); i++)
  13. if(v[i]==a)
  14. return true;
  15. return false;
  16. }
  17.  
  18. int _tmain(int argc, _TCHAR* argv[])
  19. {
  20. vector<int> vv;
  21. int* v;
  22. int n;
  23. cin >> n;
  24.  
  25. v=new int[n];
  26.  
  27. for(int i=0; i<n; i++)
  28. cin >> v[i];
  29.  
  30.  
  31. for(int i=0; i<n; i++)
  32. {
  33. if(!exist(v[i],vv))
  34. {
  35. cout << v[i] << " ";
  36. vv.push_back(v[i]);
  37. }
  38. }
  39.  
  40. system("pause");
  41. return 0;
  42. }
Add Comment
Please, Sign In to add comment