C++对拍程序**!不是bat批处理**
:
#include<bits/stdc++.h>
using namespace std;
double clock(double x)
{
return x*1000/CLOCKS_PER;
}
int main()
{
clock_t s,t,t2;
register int i=1;
for(;;++i)
{
system("data.exe > in.txt");
s=clock();
system("std.exe < in.txt > stdout.txt");
t=clock();
system("test.exe < in.txt > testout.txt");
t2=clock();
if(system("fc /W stdout.txt testout.txt > nul"))
{
printf("point #%d\nWA time used: std %.2lfms test %.2lfms\n",i,clock(t-s),clock(t2-t));
break;
}
printf("point #%d\nAC time used: std %.2lfms test %.2lfms\n",i,clock(t-s),clock(t2-t));
}
system("pause>nul");
return 0;
}
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
for (int i=1;i<=100000;i++)
{
system("C:\\random.exe");
double st=clock();
system("C:\\sol.exe");
double ed=clock();
system("C:\\bf.exe");
if (system("fc soldata.out bfdata.out")==0) {
printf("Accepted, 测试点 #%d, 用时 %.0lfms\n",i,ed-st);
} else
{
printf("Wrong Answer");
return 0;
}
}
return 0;
}
随机函数
#include<cstdio>
#include<ctime>
using namespace std;
int main()
{
srand((unsigned)time(NULL));
int n=rand();
}