Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod{
- int info;
- nod* adr;
- };
- nod *v, *s;
- void creare(nod* &v,nod* &s,int x)
- {
- nod *c;
- if(v==0)
- {
- v=new nod;
- v->info=x;
- v->adr=0;
- s=v;
- }
- else{
- c= new nod;
- s->adr=c;
- c->info=x;
- c->adr=0;
- s=c;
- }
- }
- void tip(nod *v)
- {
- nod *c=v;
- while(c)
- {
- cout<<c->info<<" ";
- c=c->adr;
- }
- }
- int main()
- {
- creare(v,s,7);
- creare(v,s,9);
- creare(v,s,11);
- tip(v);
- }
Advertisement
Add Comment
Please, Sign In to add comment