RT
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int a,ans,ipt,ansb,boom;
int t,n;
int check(int input)
{
int ret;
暴力
return ret;
}
signed main()
{
srand(time(0));
t=对拍组数;
for(int ii=1;ii<=t;ii++)
{
ipt=rand()%数据范围;
ofstream dout("example.in");
system("example.exe");
ifstream din("example.out");
din>>ans;
system("cls");
ansb=check(ipt);
if(ans!=ansb)
{
cout<<ipt<<endl;
cout<<ans<<" "<<ansb<<endl;
boom++;
system("pause");
}
}
cout<<boom<<" / "<<t<<endl;
}
主要是通过cmd指令集来实现两个程序之间的交互的。注意文件读入的开启一定要在调用正解程序之后,不然会读到上一组数据的答案从而导致错误。
其次,该程序需和被测试程序处于同一个子目录下。若实在无法做到可以在文件读入输出中打绝对路径。
再然后,注意被测试程序需要文件读写(文件读写文件名与本代码中的一致),且.cpp文件名也应与本代码中调用的exe文件名一致。
最后,在对拍前需先编译被测试程序