Bun venit Guest | RSS
Bine ati venit la 9C acasa
Meniul Site-ului
Horoscop
Exprima-ti opinia
Ce parere aveti despre site?
1. Foarte buna
2. Foarte proasta
3. Buna
4. Normal
5. Proasta
[ Vezi rezutat ยท Arhiva ]
Raspunsuri: 42
Mini chat

Info


Main » 2011 » Ianuarie » 10 » adaugare nod
adaugare nod
08:14
#include<iostream.h>

struct nod
{int info;
nod *adr;};
nod *a,*b;
int n,i;

void creare(int s)
{nod *c;
c=new nod;
cout<<"nodul "<<s<<endl;
int x;
cout<<"x=";
cin>>x;
c->info=x;
c->adr=a;
a=c;}

void afisare(nod *c)
{if(c->adr!=NULL)
afisare(c->adr);
cout<<c->info<<" ";}

void adaugare()
{int y,z;
b=a;
cout<<"inainte de ce element adaugam";
cin>>y;
cout<<"noua informatie este=";
cin>>z;
while(b->info!=y)
b=b->adr;
nod *d;
d=new nod;
d->info=z;
d->adr=b->adr;
b->adr=d;
}

      
void main()
{cout<<"n=";
cin>>n;
a=new nod;
a=NULL;
cout<<"introduceti nodurile"<<endl;
for(i=1;i<=n;i++)
creare(i);
afisare(a);
cout<<endl;
adaugare();
afisare(a);

}
Views: 330 | Added by: Iulian
Only registered users can add comments.
[ Registration | Login ]
Logheaza-te
Calendar
«  Ianuarie 2011  »
DuLuMaMiJoViSa
      1
2345678
9101112131415
16171819202122
23242526272829
3031
Meteo
Curs Valutar
Curs Valutar BNR
Cautare
Link-uri
Statistica
Director web gratuit - Afisare Thumbnail, Transfer Google PageRank, Meta keywords si meta description personalizate pentru fiecare link Site clasei 9C Colegiul National Mihai Eminescu, Muzica Stiri Sport, Filme Top66 Statistici
Total online: 1
Guests: 1
Users: 0