this is my program could somebody help plz
#include <iostream.h>
#include <string>
using namespace std;
typedef int ComponentType;
struct CropType
{
string crop;
string farmer;
string color;
};
CropType myCrop;
struct TreeNode
{
CropType info;
TreeNode* left;
TreeNode* right;
};
void Insert ( /* in */ ComponentType item);
void Inorder (TreeNode* root);;
int main()
{
string command;
ComponentType item;
TreeNode* root;
root = new TreeNode;
do
{
cout << " Please Enter a command" << endl;
cout << " Insert To Enter new data" << endl;
cout << " Find To Search the Tree" << endl;
cout << " Remove To delete data" << endl;
cout << " Dump1 For Inorder Traversal " <<endl;
cout << " Dump2 For Preorder Traversal " <<endl;
cout << " Dump3 For Postorder Traversal " <<endl;
cout << " Quit To exit" << endl;
cin >> command;
if (command == "Insert")
{
cout << "Please Enter a Crop" << endl;
cin >> myCrop.crop;
cout << "Please Enter a Farmer" << endl;
cin >> myCrop.farmer;
cout << "Please Enter an Order" << endl;
cin >> myCrop.order;
cout << "Please Enter a Color" << endl;
cin >> myCrop.color;
Insert();
}
Insert (root,info);
}while (command != "Quit");
cout << "This is your info" << " " << Inorder(root) << endl;
return 0;
}
void Insert(TreeNode*& root, CropType &item)
{
if (root==NULL)
{
root = new TreeNode;
root->left = NULL;
root->right = NULL;
root->info = item;
}
else if (item < root->info)
{
Insert(root->left, item);
}
else
{
Insert(root->right, item);
}
}
void Inorder (TreeNode* root)
{
if(root != NULL)
{
Inorder(root->left);
cout << root->info;
Inorder(root->right);
}
}
Jayrrus 0 Newbie Poster
ArkM 1,090 Postaholic
Jayrrus 0 Newbie Poster
Sky Diploma 571 Practically a Posting Shark
Jayrrus 0 Newbie Poster
ArkM 1,090 Postaholic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.