Hello everyone
I write this C++ code about (binary search tree structure)
I wrote header file and implementation file and I sure it's write
the problem with switch ,,, cases doesn't work .. only default one
and the output like that
http://
I write this C++ code about (binary search tree structure)
I wrote header file and implementation file and I sure it's write
the problem with switch ,,, cases doesn't work .. only default one
Tree my_tree; char choice[2]; char x; char y; my_tree.insert('A'); my_tree.insert('B'); my_tree.insert('F'); my_tree.insert('G'); my_tree.insert('T'); my_tree.insert('R'); my_tree.insert('M'); my_tree.insert('K'); my_tree.insert('X'); do{ cout<<"Please enter a chrecter to choose from the list: "<<endl; cout<<"'I' to insert a character."<<endl; cout<<"'S' to search for a character"<<endl; cout<<"'TI' for inorder traversal"<<endl; cout<<"'TP' for inorder traversal"<<endl; cout<<"'QU' to quit"<<endl; gets (choice); switch (choice[2]){ case 'I': case 'i': cout<<"Enter a charecter to insert: "; x=getchar(); my_tree.insert(x); break; case 'S': case 's': cout<<"Enter a charecter to search: "; y=getchar(); if(my_tree.search(y)) cout<<"The charecter is exist"; else cout<<"The charecter isn't exist"; break; case 'TI': case 'ti': inorderPrint(my_tree); break; case 'TP': case 'tp': preorderPrint(my_tree); break; default: cout<<"Invalid choice"<<endl<<endl; }// end switch }while (choice[2] != 'qu' || choice[2] !='QU');
and the output like that
http://