#include
#include
int main()
{struct nod { int x;
nod *urm;}*u,*p,*l,*p1,*u1;
int i;
p=new nod;
p->x=1;
u=p;
u->urm=NULL;
for(i=2;i<=7;i++)
{l=new nod;
l->x=i;
u->urm=l;
u=l;
u->urm=NULL;}
l=p;
p1=new nod;
p1=l;
p=p->urm;
u1=new nod;
u1=p;
p1->urm=u1;
u1->urm=NULL;
p=p->urm;
l=new nod;
l->x=11;
u1->urm=l;
u1=l;
u1->urm=NULL;
u1->urm=p;
l=p1;
while(l!=NULL)
{cout<
l=l->urm;}
return 0;}
sa se puna in stiva.Acesta trebuie asezat deasupra unui caiet de aceeasi culoare cu el/Realizati un program pentru acest lucru.
#include
#include
#include
int main()
{struct nod{ char c[20];
nod *urm;} *vf,*q,*vf2;
int i,n;
cout<<"n=";cin>>n;
vf=new nod;
vf->urm=NULL;
cin>>vf->c;
for(i=2;i<=n;i++)
{q=new nod;
q->urm=vf;
vf=q;
cin>>vf->c;}
vf2=NULL;
while(strcmp(vf->c,"galben")!=0 && vf!=NULL)
{q=vf;
if(vf2==NULL)
{vf2=new nod;
vf2=q;vf2->urm=NULL;
vf=vf->urm;}
else
{q=vf;
q->urm=vf2;
vf2=q;
vf=vf->urm;}}
q=new nod;
strcpy(q->c,vf->c);
q->urm=vf;
vf=q;
while(vf2!=NULL)
{vf2->urm=vf;
vf=vf2;
vf2=vf2->urm;}
while(vf!=NULL)
{cout<
vf=vf->urm;}
return 0;}