Pagini recente » Cod sursa (job #1364685) | Cod sursa (job #513124) | Cod sursa (job #3221376) | Cod sursa (job #1943698) | Cod sursa (job #1580680)
#include<fstream>
#define r 665124
using namespace std;
struct nod
{
int info;
nod *adr;
};
nod *v[r];
ifstream f("hashuri.in");
ofstream g("hashuri.out");
void adaug (nod *&p,int x)
{
nod *q=new nod;
q->info=x;
q->adr=p;
p=q;
}
void sterge (nod *&p, int x)
{
if(p==NULL)
return;
nod *aux=new nod;
if(p->info==x)
{
aux=p;
p=p->adr;
delete aux;
return;
}
for (nod* q=p;q->adr;q=q->adr)
{
if(q->adr->info==x)
{
aux=p->adr;
p->adr=aux->adr;
delete aux;
return;
}
}
}
void raspuns (nod *p, int x)
{
int contor=0;
while (p!=NULL)
{
if(p->info==x)
contor=1;
p=p->adr;
}
if(contor==1)
g<<1;
else
g<<0;
g<<'\n';
}
int main ()
{
long int n,a,b;
f>>n;
while (n!=0)
{
f>>a;
f>>b;
if(a==1)
adaug(v[b%r],b);
if(a==2)
sterge(v[b%r],b);
if(a==3)
raspuns(v[b%r],b);
n--;
}
f.close();
g.close();
return 0;
}