window c++ 对拍

首先,对拍是个好东西。

需要一个保证正确输出的代码,我们将它命名为 r i g h t . c p p right.cpp right.cpp

e.g.

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;	
	cout<<a+b;
	return 0;
}
然后将你的代码,命名为 m i n e . c p p mine.cpp mine.cpp

e.g.

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;	
	printf("%d",a+b);
	return 0;
}
然后需要一个数据生成代码,命名为 r a n d . c p p rand.cpp rand.cpp

e.g.

#include<bits/stdc++.h>
using namespace std;
int main()
{
	srand(time(0));
	int a,b;
	a=rand()%100+1,b=rand()%100+1;
	printf("%d %d\n",a,b);
	return 0;
}
最后需要一个对拍的代码 ,我们将它命名为 k i n g . c p p king.cpp king.cpp
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
	for(int t=1; t<=1000; t++)
	{
		printf("NO.%d\n",t);
		system("rand.exe > rand.txt");
		system("right.exe < rand.txt > right.txt");
		system("mine.exe < rand.txt > mine.txt");
		if(system("fc mine.txt right.txt"))
		{
			puts("error");
			break;
		}
		else puts("PASS%%%%");
	}
	return 0;
}
保证他们都在同一个文件夹中

编译运行 right.cpp rand.cpp mine.cpp
生成 right.exe rand.exe mine.exe
然后运行 king.cpp
(各个cpp的输出数据会保存在各个的txt文件中)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值