输出两文件结果的差异和输入的文件(基于Linux的命令,仅适用于Linux)
样式为
1 1 //左边为my.out 右边为text.out,并行输出,将指令'-y -W 50'修改为'-c'可改为竖直输出
2 | 1 //其中的|号为差异点,无|的为相同的
input: //输出input.in文件
1
904532930303613184
WA
对拍程序battle.cpp
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
int i=0;
while(1){
system("./data");
system("./my");
system("./text");
printf("%d : ",i++);
if (system("diff my.out text.out")){
printf("\n\ncompare:\n");
system("diff my.out text.out -y -W 50");
printf("\n\ninput:\n");
system("cat input.in");
printf("\nWA\n");
return 0;
}
else printf("AC\n");
}
return 0;
}
数据文件data.cpp
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<ctime>
using namespace std;
const long long MOD=1e18;
int main()
{
// cout<<RAND_MAX<<endl;
freopen("input.in","w",stdout);
srand(time(NULL));
int t=1;
cout<<t<<endl;
while(t--){
long long n=(long long )((double)(1.0*rand()*MOD)/RAND_MAX);
cout<<n<<endl;
}
return 0;
}
正确程序或暴力程序text.cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("input.in","r",stdin);
freopen("text.out","w",stdout);
return 0;
}
自己程序my.cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("input.in","r",stdin);
freopen("my.out","w",stdout);
return 0;
}