Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod{
- int info;
- nod *leg;
- };
- nod* creare(){
- int n;
- cin>>n;
- if(n==0) return 0;
- else{
- nod *p;
- nod *prim=new nod;
- prim->info=n;
- p=prim;
- cin>>n;
- while (n){
- nod *q=new nod;
- q->info=n;
- p->leg=q;
- p=q;
- cin>>n;
- }
- p->leg=NULL;
- return prim;
- }
- }
- void parcuregre (nod *prim){
- while (prim){
- cout<<prim->info<<endl;
- prim=prim->leg;
- }
- }
- nod *intoarecere (nod *prim){
- nod *anterior, *urmator, *curent;
- nod *p=prim;
- curent=p->leg;
- prim->leg=NULL;
- anterior=p;
- while (curent){
- urmator=curent->leg;
- curent->leg=anterior;
- anterior=curent;
- curent=urmator;
- }
- return anterior;
- }
- int main()
- {
- nod *p=creare();
- nod *q=intoarecere(p);
- parcuregre(q);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement