Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. int main(int argc, char *argv[])
  2. {
  3. FILE* fr;
  4. FILE* fo;
  5. int ai = 0;
  6. int i = 0;
  7. char* in = argv[1]; //input
  8. char* out = argv[2]; //output
  9. char* s1;
  10. char* s2;
  11. char line[100]; //just because
  12. char w;
  13. const char* x = "";
  14. heap h; // heap
  15.  
  16. fr = stdin;
  17. fo = stdout;
  18.  
  19.  
  20. while (fgets(line, 90, fr) != NULL){
  21. w = line[0];
  22.  
  23. switch (w){
  24. case 'B':
  25. h = build(atol(line + 2));
  26. break;
  27. case 'G':
  28. fprintf(fo, "%s%d",x, GetMin(h));
  29. x = "\n";
  30. break;
  31. case 'X':
  32. xMin(h);
  33. break;
  34. case 'I':
  35. ai=insert(h, atol(line + 2));
  36. fprintf(fo, "%s%d",x, ai);
  37. x = "\n";
  38. break;
  39. case 'D':
  40. for (s1 = line; *s1 != ' '; s1++){}
  41. for (s2 = s1 + 1; *s2 != ' '; s2++){}
  42. decKey(h, atol(s1), atol(s2));
  43. break;
  44. case 'P':
  45. fprintf(fo, "%s%d",x, phi(h));
  46. x = "\n";
  47. break;
  48. case 'R':
  49. fprintf(fo, "%s%d", x,h->A[atol(line + 2)].r);
  50. x = "\n";
  51. break;
  52. case 'E':
  53. free(h->A);
  54. free(h->C);
  55. free(h);
  56. break;
  57. default:
  58. printf("none of the above");
  59. break;
  60.  
  61. }
  62. }
  63.  
  64.  
  65. fclose(fr);
  66. fclose(fo);
  67.  
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement