#include<fstream.h>
fstream f("date1.in",ios::in);
struct nod{ int info;
nod *leg;
};
nod *prim;
void adaug( nod *&prim,int nr)
{ nod * c=new nod;
c->info=nr;
c->leg=prim;
prim=c;
}
void afis(nod *prim)
{ nod * c=prim;
while(c)
{cout<<c->info<<" ";
c=c->leg;
}
}
void stergpar(nod*&prim)
{ nod *p,*q;
while(prim->info%2==0)
{q=prim;
prim=prim->leg;
delete q;
}
p=prim;
while(p->leg)
if(p->leg->info %2==0)
{q=p->leg;
p->leg=q->leg;
delete q;
}
else p=p->leg;
}
void main()
{ int x;
while(f>>x)
adaug(prim,x);
afis(prim);
stergpar(prim);
afis(prim);
}
|