Pagini recente » Cod sursa (job #1065975) | Cod sursa (job #747721) | Cod sursa (job #1045936)
#include <vector>
#include <ostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <stdio.h>
using namespace std;
fstream f, g;
int main()
{
f.open("hashuri.in", ios::in);
g.open("hashuri.out", ios::out);
vector <int> v;
int n, i, op, x;
f>>n;
for(i=1;i<=n;i++)
{
f>>op>>x;
switch(op)
{
case 1:
if(find(v.begin(),v.end(),x) == v.end())
v.push_back(x);
break;
case 2:
if(find(v.begin(),v.end(),x) != v.end())
{
vector<int>::iterator position = find(v.begin(), v.end(), x);
if (position != v.end())
v.erase(position);
}
break;
case 3:
if(find(v.begin(),v.end(),x) != v.end())
g<<1<<"\n";
else
g<<0<<"\n";
break;
}
}
f.close();
g.close();
return 0;
}