Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FILE* fr;
- FILE* fo;
- int ai = 0;
- int i = 0;
- char* in = argv[1]; //input
- char* out = argv[2]; //output
- char* s1;
- char* s2;
- char line[100]; //just because
- char w;
- heap h; // heap
- fr = fopen(in, "rt");
- fo = fopen(out, "w+");
- while (fgets(line, 90, fr) != NULL){
- char w = line[0];
- switch (w){
- case 'B':
- h = build(atol(line + 2));
- break;
- case 'G':
- fprintf(fo, "%d\n", GetMin(h));
- break;
- case 'X':
- xMin(h);
- break;
- case 'I':
- ai=insert(h, atol(line + 2));
- fprintf(fo, "%d\n", ai);
- break;
- case 'D':
- for (s1 = line; *s1 != ' '; s1++){}
- for (s2 = s1 + 1; *s2 != ' '; s2++){}
- decKey(h, atol(s1), atol(s2));
- break;
- case 'P':
- fprintf(fo, "%d\n", phi(h));
- break;
- case 'R':
- fprintf(fo, "%d\n", h->A[atol(line + 2)].r);
- break;
- case 'E':
- free(h->A);
- free(h->C);
- free(h);
- break;
- default:
- printf("none of the above");
- break;
- }
- }
- fclose(fr);
- fclose(fo);
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement