Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include<iostream.h> #include<conio.

h> struct nod{int nro; nod*st,*dr;}; nod *r; void svd(nod *c) {if(c) {svd(c->st); cout<<c->nro<<" "; svd(c->dr); } } void vsd(nod *c) {if(c) {cout<<c->nro<<" "; vsd(c->st); vsd(c->dr); } } void sdv(nod *c) {if(c) {sdv(c->st); sdv(c->dr); cout<<c->nro<<" "; } } nod* citire_h() {int nr; nod*c; cout<<"nr de ordine "; cin>>nr; if(nr) {c=new nod; c->nro=nr; c->st=citire_h(); c->dr=citire_h(); return c; } else return 0; } void main() {clrscr(); r=citire_h(); cout<<endl<<"parcurgere svd - in inordine "<<endl; svd(r); cout<<endl<<"parcurgere vsd - in preordine "<<endl; vsd(r); cout<<endl<<"parcurgere sdv - in postordine "<<endl; sdv(r); getch();

You might also like