Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. bool readArgument(){
  2.     char* command = (char*)malloc(1024);
  3.     int value;
  4.     scanf("%s", command);
  5.     //puts(command);
  6.     if(!strcmp(command,"insertNode")) {
  7.         scanf("%d", &value);
  8.         root = insertNode(root, value);
  9.         return true;
  10.     }
  11.     else if(!strcmp(command,"find")){
  12.         scanf("%d", &value);
  13.         find(root, value);
  14.         return true;
  15.     }
  16.     else if(!strcmp(command,"inorder")){
  17.         printInorder(root);
  18.         puts("");
  19.         return true;
  20.     }
  21.     else if(!strcmp(command,"min")){
  22.         findMin(root, true);
  23.         return true;
  24.     }
  25.     else if(!strcmp(command,"max")){
  26.         findMax(root);
  27.         return true;
  28.     }
  29.     else if(!strcmp(command,"delete")){
  30.         scanf("%d", &value);
  31.         root = deleteNode(root, value);
  32.         return true;
  33.     }
  34.     else if(!strcmp(command,"parent")){
  35.         scanf("%d", &value);
  36.         Node* parent = findParent(root, findAndReturn(root, value));
  37.         printf("Parent of %d is %d",value, parent->data);
  38.     }
  39.     else {
  40.         return false;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement