int choice=0;
BST intTree;
do
{
system("cls");
cout <<"\n================MENU=================";
cout <<"\n1. Tao cay nhi phan gom n nut, moi nut luu 1 phan tu cua mang so nguyen cho truoc";
cout <<"\n2. Xuat cay theo thu tu tang dan";
cout <<"\n3. Xuat cay theo thu tu giam dan";
cout <<"\n4. Nut chua khoa X";
cout <<"\n5. Nut co gia tri lon nhat";
cout <<"\n6. Nut co gia tri nho nhat";
cout <<"\n7. Tong cac node tren cay";
cout <<"\n8. Xoa node co gia tri la x";
cout <<"\n9. Thoat";
cout <<"\nNhap lua chon: ";
cin>>choice;
switch (choice)
{
case 1:{
int n;
cout <<"\nNhap so phan tu cua mang";
cin >>n;
int *a=new int[n];
for (int i = 0; i < n; i++)
{
cout <<"\nx["<<i<<"]= ";
cin>>a[i];
intTree.insert(intTree.getRoot(),a[i]);
}
delete a;
break;
}
case 2:{
cout <<"\n----Xuat theo chieu tang dan----";
intTree.inOrderInCrease(intTree.getRoot());
break;
}
case 3:{
cout <<"\n----Xuat theo chieu giam dan----";
intTree.inOrderDecrease(intTree.getRoot());
break;
}
case 4:{
int x;
cout <<"\nNhap gia tri x: ";
cin>>x;
intTree.search(intTree.getRoot(),x);
cout <<"\nDa tim thay node co gia tri ";
break;
}
case 5:{
Node *temp=intTree.minValue(intTree.getRoot());
cout <<"\nNode co gia tri nho nhat co gia tri la: \t"<<temp->data;
break;
}
case 6:{
Node *temp=intTree.maxValue(intTree.getRoot());
cout <<"\nNode co gia tri nho nhat co gia tri la: \t"<<temp->data;
break;
}
case 7:{
cout <<"\nTong cac gia tri cua node la: "<<intTree.sumValue(intTree.getRoot());
break;
}
case 8:{
int x;
cout <<"\nNhap gia tri can xoa";
cin>>x;
intTree.reMove(intTree.getRoot(),x);
cout <<"\nDa xoa thanh cong";
}
default:
break;
}
system("pause");
} while (choice !=9);
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}