首页 > 技术文章 > c++ 对拍器

wuwendongxi 2020-08-10 17:13 原文

使用注意

  • 数据生成程序data,要提交的程序mycode,暴力/正确的代码correct
  • 使三个代码在同一文件夹下
  • 所有代码不加文件输入输出
  • 所有代码再devc++编译器下使用,使用前先编译,保证有最新的exe文件

代码

#include<cstdio>
#include<cstdlib>
#include<ctime>
int main()
{   long s,t;
    while(1){
        system("cls");
        do{
            system("data > data.in"); //data是数据生成程序
            s=clock();
            system("mycode < data.in > mycode.out");  //mycode是要交的程序
            t=clock();
            system("correct < data.in > correct.out");  //correct是正确的程序
            if(system("fc mycode.out correct.out > nul")) break;
            else printf("AC time: %ldms\n",t-s);
        }while(1);
        printf("WA time: %ldms\n",t-s);  //运行时间 
        system("fc mycode.out correct.out");
        system("pause>nul");
    }
    return 0;
}

推荐阅读