Pagini recente » Cod sursa (job #656435) | Cod sursa (job #929270) | Cod sursa (job #570216) | Cod sursa (job #3317678) | Cod sursa (job #850322)
Cod sursa(job #850322)
#include <fstream>
#define nmax 1000005
using namespace std;
typedef struct lista
{
long info;
lista *leg;}
TLISTA;
TLISTA a[nmax];
int main()
{TLISTA *p,*q;
int x,n,indice,op,i;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>n;
for(i=1;i<=n;i++)
{
f>>op>>x;
indice=x%10000-1;
p=a+indice;
if (op==1)
{while (p->leg&&p->info!=x)
p=p->leg;
if (p->info!=x)
{q=new TLISTA;
q->info=x;
q->leg=NULL;
p->leg=q;}}
else
if(op==2)
{
while(p->leg&&p->leg->info!=x)
p=p->leg;
if (p->leg)
{q=p->leg;
p->leg=p->leg->leg;
delete q;}}
else
if (op==3)
{
while(p->leg&&p->info!=x)
p=p->leg;
if (p->info==x)
g<<1<<"\n";
else g<<0<<"\n";}}
f.close();
g.close();
return 0;
}