无限对拍程序

折叠代码之后博客就变短了好多呢。

like this
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;

int cas;

int main(){
    while(1){
        Sleep(50);
        system("data.exe");//生成数据
        system("std.exe");//你的两份代码的exe文件1
        system("test.exe");//你的两份代码的exe文件2
        printf("-----------Test Case %d----------\n",++cas);
        if(system("fc test.out test.ans")) system("pause");
    }
    return 0;
}
这里还有一份不用freopen的对拍程序
#include <cstdio>
#include <cstdlib>
#include <windows.h>
using namespace std;

int main()
{
	//For Windows
	//对拍时不开文件输入输出
	//当然,这段程序也可以改写成批处理的形式
	int tot = 0;
	while(1)
	{
		printf("Test Data %d :\n",++tot);
		system("Create_Data.exe > data.in");//数据生成器将生成数据写入输入文件
		system("my_code.exe < data.in > mine.out");//获取程序1输出
		system("brute_force.exe < data.in > data2.out");//获取程序2输出
		if(system("fc mine.out data2.out"))
		{
   			//该行语句比对输入输出
			//fc返回0时表示输出一致,否则表示有不同处
			system("pause");//方便查看不同处
			//该输入数据已经存放在data.in文件中,可以直接利用进行调试
		}
	}
}
无注释版本
#include <cstdio>
#include <cstdlib>
#include <windows.h>
using namespace std;

int main()
{
	int tot = 0;
	while(1)
	{
		printf("Test Data %d :\n",++tot);
		system("Create_Data.exe > data.in");
		system("my_code.exe < data.in > mine.out");
		system("brute_force.exe < data.in > data2.out");
		if(system("fc mine.out data2.out"))
			system("pause");
	}
}
生成数据
//12252024832524
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define TT template<typename T>
using namespace std; 

typedef long long LL;
const int MAXN = 100005;
int n;

LL Read()
{
	LL x = 0,f = 1;char c = getchar();
	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
	return x * f;
}
TT void Put1(T x)
{
	if(x > 9) Put1(x/10);
	putchar(x%10^48);
}
TT void Put(T x,char c = -1)
{
	if(x < 0) putchar('-'),x = -x;
	Put1(x); if(c >= 0) putchar(c);
}
TT T Max(T x,T y){return x > y ? x : y;}
TT T Min(T x,T y){return x < y ? x : y;}
TT T Abs(T x){return x < 0 ? -x : x;}

LL Rand(LL l,LL r){return (1ll * rand() * rand() * rand() + rand()) % (r-l+1) + l;}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	srand(time(0));
	
	return 0;
}

注意文件名不要重名,哪怕后缀名不一样也不行。

posted @ 2020-08-27 07:50  皮皮刘  阅读(139)  评论(0编辑  收藏  举报