Pagini recente » Cod sursa (job #2820518) | Cod sursa (job #1994306) | Cod sursa (job #2303624) | Cod sursa (job #2584592) | Cod sursa (job #1044977)
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
struct nod{int info;
nod *next;};
nod *a;
void add(int x)
{
nod *c;
c=new nod;
c->info=x;
c->next=a;
a=c;
}
void del(int x)
{
if(a->info==x)
a=a->next;
else
{
nod *c=a;
while(c->next->info!=x)
c=c->next;
c->next=c->next->next;
}
}
int search(int x)
{
nod *c=a;
while(c && c->info!=x)
c=c->next;
if(c)
return 1;
return 0;
}
int main()
{
long n,x,y,i;
a=new nod;
a=NULL;
f>>n;
for(i=1;i<=n;i++)
{
f>>x>>y;
if(x==1)
{
if(search(x)==0)
add(x);
}
else
if(x==2)
{
if(search(x)==1)
del(x);
}
else
g<<search(x)<<endl;
}
return 0;
}