Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // s2.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <vector>
- #include <iostream>
- using namespace std;
- bool exist(int a, const vector<int>& v)
- {
- for(int i=0; i<v.size(); i++)
- if(v[i]==a)
- return true;
- return false;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- vector<int> vv;
- int* v;
- int n;
- cin >> n;
- v=new int[n];
- for(int i=0; i<n; i++)
- cin >> v[i];
- for(int i=0; i<n; i++)
- {
- if(!exist(v[i],vv))
- {
- cout << v[i] << " ";
- vv.push_back(v[i]);
- }
- }
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment