#include<iostream.h>
#include<string.h>
struct nod
{ char info;
nod *prec, *urm;
};
nod *prim;
void adaugs(nod *&prim, char x)
{ nod *p, *nou;
if(prim)
{ p=prim;
while(p->urm) p=p->urm;
nou=new nod;
nou->info=x;
p->urm=nou;
nou->prec=p;
nou->urm=0;
}
else
{ prim=new nod;
prim->info=x;
prim->urm=0;
prim->prec=0;
}
}
void afis(nod *prim)
{ nod *p=prim;
while(p->urm) p=p->urm;
while(p)
{ cout<<p->info;
p=p->prec;
}
}
void main()
{ char s[30];
cin>>s;
for(int i=0;i<strlen(s); i++) adaugs(prim,s[i]);
afis(prim);
} |