Pagini recente » Cod sursa (job #3214393) | Cod sursa (job #1212704) | Cod sursa (job #700594) | Cod sursa (job #632773) | Cod sursa (job #607287)
Cod sursa(job #607287)
#include <iostream.h>
#include <fstream.h>
#define N 1000001
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int v[N],k=0;
void hAdd(int x);
void hDelete(int x);
int hCheck(int x);
//void afiseaza();
int main()
{
int n,i,op,x;
f>>n;
for(i=1;i<=n;i++)
{
f>>op>>x;
switch(op)
{
case 1:
hAdd(x);
break;
case 2:
hDelete(x);
break;
case 3:
g<<hCheck(x)<<"\n";
break;
}
afiseaza();
}
f.close();
g.close();
return 0;
}
void hAdd(int x)
{
v[++k]=x;
}
void hDelete(int x)
{
for(int i=1;i<=k;i++)
if(v[i]==x)
for(int j=i;j<=k;j++)
v[j]=v[j+1];
}
int hCheck(int x)
{
for(int i=1;i<=k;i++)
if(v[i]==x)
return 1;
return 0;
}
/*void afiseaza()
{
for(int i=1;i<=k;i++)
cout<<v[i]<<" ";
cout<<endl;
}*/