Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- ifstream fin("arbore2.txt");
- struct ARB{int nod;
- ARB *S, *D;};
- ARB *R;
- int n;
- void inserare(ARB *&c,int k)
- {
- if(c)
- {if(c->nod<k)
- inserare(c->D,k);
- else
- inserare(c->S,k);}
- else
- {c=new ARB;
- c->nod=k;
- c->S=c->D=NULL;}
- }
- void SVD(ARB *a)
- {
- if(a)
- {
- SVD(a->S);
- cout<<a->nod<<" ";
- SVD(a->D);
- }
- }
- int main()
- {
- cout<<"Nod= ";
- cin>>n;
- while(n!=0)
- {
- inserare(R,n);
- cout<<"Nod= ";
- cin>>n;}
- cout<<"SVD = ";
- SVD(R);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement