C++ 对拍程序

#include<cstdio>
#include<cstdlib>
#include<ctime>

int main()
{   long s,t;
    while(1){
        system("cls");
        do{
            system("data.exe > data.txt"); //data是数据生成程序
            s=clock();
            system("2.exe < data.txt > try2.out");  //a是要交的程序
            t=clock();
            system("1.exe < data.txt > try1.out");  //b是正确的程序
            if(system("fc try1.out try2.out > nul"))
                break;
            else printf("AC time: %ldms\n",t-s); //并输出运行时间
        }while(1);
        printf("WA time: %ldms\n",t-s);  //运行时间
        system("fc try1.out try2.out");
        system("pause>nul");
    }
    return 0;
}

data.exe 是生成数据的程序

2.exe 是要提交的程序

1.exe 是一定正确的程序

猜你喜欢

转载自blog.csdn.net/ii0789789789/article/details/81174968