#include #include # include #include bool b = 0; // ----------- VEHICLE STRUCTURE ----------- // struct Vehicle { char vehicle_type [100], maker [100], engine_no [100], registration_no [100]; int year_of_manufacture; unsigned int vehicle_price; enum vehicle_class {Motor_Cycle, Car, Van, Sports_Car, Pickup, Truck}vc; }; // --------------------------------------- // // ----------- OWNER STRUCTURE ----------- // struct Owner { char owner_name [100], father_name [100], address [100], transferred_from [100]; int date_of_purchase, month_of_purchase, year_of_purchase; Vehicle v; } owner1 = {"Ali Hussain", "Muhammad Hussain", "XYZ, Lahore", "N/A", 12, 12,2012, "4-Wheel", "Honda", "BR-29536", "LEV-0012", 2011, 72000, Vehicle::Van}; // --------------------------------------- // // ----------- FUNCTION VIEW ----------- // void View (struct Owner *o2) { char * vclass; { if (o2->v.vc == 0) vclass = "Motor Cycle"; else if (o2->v.vc == 1) vclass = "Car"; else if (o2->v.vc == 2) vclass = "Van"; else if (o2->v.vc == 3) vclass = "Sports Car"; else if (o2->v.vc == 4) vclass = "Pickup"; else if (o2->v.vc == 5) vclass = "Truck"; else vclass = "Unknown Vehicle Class"; } cout<<"===================="<v.registration_no<v.vehicle_type<v.maker<v.year_of_manufacture<v.engine_no<v.vehicle_price<owner_name<father_name<address<date_of_purchase<<" / "<month_of_purchase; cout<<" / "<year_of_purchase<transferred_from<transferred_from, o2->owner_name); cout<<"Buyer Name: "; cin.sync(); cin.getline (o2->owner_name, 100); cout<<"Father's Name: "; cin.getline (o2->father_name, 100); cout<<"Address: "; cin.getline(o2->address, 100); cout<<"Date of Purchasing: "; cin>>o2->date_of_purchase; cout<<"Month of Purchasing: "; cin>>o2->month_of_purchase; cout<<"Year of Purchasing: "; cin>>o2->year_of_purchase; b = 1; } // ----------------------------------------- // // ----------- FUNCTION Register ----------- // void Register (struct Owner *o2) { int enum_choice; cout<<"================================="<v.registration_no, 100); cout<<"Vehicle Type: "; cin.getline (o2->v.vehicle_type, 100); cout<<"Vehicle Class (0 - 5): "; cin>>enum_choice; o2->v.vc = (Vehicle::vehicle_class)enum_choice; cin.sync(); cout<<"Maker: "; cin.getline (o2->v.maker, 100); cout<<"Year of Manufacture: "; cin>>o2->v.year_of_manufacture; cin.sync(); cout<<"Engine No: "; cin.getline (o2->v.engine_no, 100); cout<<"Vehicle Price: "; cin>>o2->v.vehicle_price; cout<<"=================="<owner_name, 100); cout<<"Father's Name: "; cin.getline (o2->father_name, 100); cout<<"Address: "; cin.getline(o2->address, 100); cout<<"Date of Purchasing: "; cin>>o2->date_of_purchase; cout<<"Month of Purchasing: "; cin>>o2->month_of_purchase; cout<<"Year of Purchasing: "; cin>>o2->year_of_purchase; } // ----------------------------------------- // int main () { int choice; Owner *owner2 = &owner1; cout<<"==========================="<>choice; switch (choice) { case 1: { system ("cls"); View (owner2); break; } case 2: { system ("cls"); Transfer (owner2); system ("cls"); View (owner2); break; } case 3: { system ("cls"); Register (owner2); system ("cls"); View (owner2); break; } default: exit (0); } getch(); return 0; } #include #include //For the required binary tree implementation, two traversals of the tree are required; //Pre Order Traversal and In Order Traversal // TreeNode class to create a new node as well as set and get values from it. class TreeNode { public: //constructor TreeNode(int value) { this->value = value; this->left = NULL; this->right = NULL; } //get and set value of the node int getInfo() { return this->value; } void setInfo(int value) { this->value = value; } //left child TreeNode* getLeft() { return left; } void setLeft(TreeNode* left) { this->left = left; } //right child TreeNode* getRight() { return right; } void setRight(TreeNode* right) { this->right = right; } //Private data memebers include value of a node, left and right child private: int value; TreeNode* left; TreeNode* right; }; //End of class TreeNode //findposition(...) function is used to find the index of a node value in inorder traversal array. int findPosition(int* arr, int val, int arrsize) { for(int i=0; isetLeft(createBTree(preorder+1, inorder, newPos)); node->setRight(createBTree(preorder+newPos+1, inorder+newPos+1, arrsize-newPos-1)); return node; } // postorder(0) function is used to print postorder traversal of the binary tree created void postorder(TreeNode* troot) { if( troot != NULL) { postorder(troot->getLeft()); postorder(troot->getRight()); cout << troot->getInfo()<<" "; } } //below is the main() function int main() { int preorderarr[] = {18,95,41,29,52,74,86,33,57,17,20}; //array to store preorder traversal of the tree int inorderarr[] = {41,95,74,52,29,18,86,57,17,33,20}; //array to store inorder traversal of the tree TreeNode* btree = createBTree(preorderarr, inorderarr, 11);//tree creat cout<<"***** Post order traversal of the given Tree ******" <