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 (){
- nod *prim;
- int nr;
- cin>>nr;
- if (nr == 0)
- return 0;
- else{
- nod *p=new nod;
- prim=p;
- p->info=nr;
- p->leg=NULL;
- cin>>nr;
- while (nr){
- nod *q=new nod;
- q->info=nr;
- p->leg=q;
- p=q;
- cin>>nr;
- }
- p->leg=NULL;
- }
- return prim;
- }
- void parcurgere (nod *prim){
- nod *p=prim;
- while (p){
- cout<<p->info<<endl;
- p=p->leg;
- }
- }
- int main()
- {
- nod *p = creare();
- parcurgere (p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement