Linux/Ubuntu系统对拍程序

输出两文件结果的差异和输入的文件(基于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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值