1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #include <windows.h> #include <stdio.h> #include <time.h>
char full_filename[100], compile_command[250], run_command[150], fc_command[300]; int id;
int main() { scanf("%s", full_filename); int len1 = strlen(full_filename); for (int i = len1 - 1; i >= len1 - 4; i--) full_filename[i] = 0;
sprintf(compile_command, "g++ -lm %s.cpp -o %s", full_filename, full_filename); printf("Compiling. . .\n");
unsigned int compile = system(compile_command);
if (!compile) { sprintf(run_command, "%s.exe", full_filename); printf("Running. . .\n");
clock_t c1 = clock(); unsigned int run = system(run_command); clock_t c2 = clock();
if (!run) { sprintf(fc_command, "fc /W /N %s.out %s.ans", full_filename, full_filename);
unsigned int fc = system(fc_command);
if (!fc) { if (c2 - c1 > 1000) printf("Time Limit Exceeded: %dms\n", c2 - c1); else printf("Accpect: %dms\n", c2 - c1); } else printf("Wrong Answer: %dms\n", c2 - c1); }
printf("Process exited with return value %u\n", run); } else printf("Compile Error!\n");
system("pause"); return 0; }
|