Pagini recente » Cod sursa (job #2298610) | Cod sursa (job #724146) | Cod sursa (job #1828269) | Cod sursa (job #2281563) | Cod sursa (job #1596122)
#include <iostream>
#include <set>
using namespace std;
int N, op, x;
set<int> theHash;
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
cin >> N;
while (N > 0)
{
scanf("%d%d",&op,&x);
switch (op)
{
case 1://insert value, if does not exist
theHash.insert(x);
break;
case 2://delete value, if exists
theHash.erase(x);
break;
case 3://try to find the value, and print output
printf("%d\n", (theHash.find(x) != theHash.end()));
break;
}
N--;
}
}