Results 1 to 2 of 2
Thread: C++
Hybrid View
-
17th December 2013 21:32 #1Registered User
Join Date: Dec:2013
Location: Ruse
Posts: 3
C++
!
:
. /, :
- ;
- ;
- ;
- ;
:
( )?Code:#include <iostream.h> struct Bukvi { char K; Bukvi *L, *R; }; typedef Bukvi* Point; Point root1,root2; void Add_A_tree(char x, Point &p) { if (p==NULL) { p=new Bukvi; p->K=x; p->L=p->R=NULL; } else if (x<p->K) Add_A_tree(x, p->L); else if (x>p->K) Add_A_tree(x, p->R); else cout<<"Ima takyv element!"; } void Add_B_tree(char x, Point &p) { if (p==NULL) { p=new Bukvi; p->K=x; p->L=p->R=NULL; } else if (x<p->K) Add_A_tree(x, p->L); else if (x>p->K) Add_A_tree(x, p->R); else cout<<"Ima takyv element!"; } void print(Point p) { if (p) { print(p->L); cout<<p->K; print(p->R); } } Point search_A_tree (int x, Point p) { while ((p)&&(x!=p->K)) { if (x<p->K) p=p->L; else p=p->R; } return p; } void merge( void main() { char b,Ch; root1=NULL; root2=NULL; cout<<"koren = "; cin>>b; while(b!='0') { Add_A_tree(b, root1); cout<<"Simvol: "; cin>> b; } cout<<"Da printiram li dyrvoto (Y/N)?: "; cin >> Ch; if(Ch=='Y' || Ch=='y'){ print(root1); cout<<"\n"; } cout<<"koren = "; cin>>b; while(b!='0') { Add_B_tree(b, root2); cout<<"Simvol: "; cin>> b; } cout<<"Da printiram li dyrvoto (Y/N)?: "; cin >> Ch; if(Ch=='Y' || Ch=='y'){ print(root2); cout<<"\n"; } }
-
18th December 2013 11:01 #2
? , /merge/ - A Merge, B ...
, , Add_A_tree Add_B_tree , , / Merge /?
----
: " ?" - smelkomar, .
: , .ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in