Pagini recente » Cod sursa (job #698772) | Cod sursa (job #2263729) | Cod sursa (job #1769536) | Cod sursa (job #141073) | Cod sursa (job #2746139)
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int nr_op , op , x;
vector<int> v;
int exista(int x)
{
for (int i =0; i<v.size(); i++)
{
if(v[i] == x)
{
return 1;
swap(v[i], v[v.size()]);
}
}
return 0;
}
int main()
{
v.empty();
fin>>nr_op;
for(int i = 0; i < nr_op; i++)
{
fin >> op >> x;
if( op == 1 )
{
if(exista(x) == 0)
{
v.push_back(x);
}
}
if( op == 2 )
{
if(exista(x) == 1)
{
v.pop_back();
}
}
if ( op == 3 )
{
if(exista(x) == 1)
{
fout << 1 << '\n';
}
else
{
fout << 0 << '\n';
}
}
}
}