对拍模板

0AND1STORY

2019-07-14 18:50:13

Personal

自己写了一个不错的对拍模板,分享给大家: ```cpp #include <cstdio> #include <cstdlib> #include <ctime> #include <windows.h> using namespace std; #define init_rand srand(time(NULL)); #define LPFILE FILE* #define infile(name) fopen(name, "w"); #define for(x, l, r) for(int x = l; x <= r; x ++) inline int rand(register int l, register int r) { return rand() % (r-l+1) + l; } inline double rand_double() { return (double)rand() / RAND_MAX; } int main() { init_rand while (true) { LPFILE fin = infile("test.in") int n = rand(1, 1000); fprintf(fin, "%d\n", n); for (i, 1, n) fprintf(fin, "%d ", rand(1,5000)); fprintf(fin, "\n"); fclose(fin); system("type test.in"); system("my.exe < test.in > my.out"); system("right.exe < test.in > right.out"); if (system("fc my.out right.out")) MessageBox(NULL, "找到差异,请查看!", "找到差异", MB_OK | MB_ICONERROR), system("pause"); } return 0; } ```