Anda di halaman 1dari 1

#include<iostream>

#include<conio.h>
using namespace std;
struct nod {
int num;
nod *leg;
};
nod * v;
int n;
void adaug(nod*& v,int n){
nod * c=new nod;
c->num=n;
c->leg=v;
v=c;
}
void list(nod* v){
nod* c=v;
while (c){
cout<<c->num<<" ";
c=c->leg;
}
}
int main(int argc,char* argv[]){
cout<<"crearea unei liste pana la citirea valorii 0"<<endl;
cout<<"dati un numar:";cin>>n;
while (n){
adaug(v,n);
cout<<"dati un numar:";cin>>n;
}
list(v);
cout<<endl;
getch();
return 0;
}