天天看點

對拍

對拍

步驟:

1.先寫出自己的代碼并運作

2.寫出暴力代碼并運作

#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
int main(){
    srand(time(0));
    freopen("in.in", "w", stdout);
    int a = rand(), b = rand();
    printf("%d %d\n", a, b);
}
           
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
    while(1){
        system("data.exe");
        system("baoli.exe");
        double begin=clock();
        system("std.exe");
        double end=clock();
        printf("運作時間%.4lf",(end-begin)/1000);
        if (system("fc std.txt baoli.txt")) //當 fc 傳回1時,說明這時資料不一樣
            break;                          //不一樣就跳出循環
        cout<<"找不到差異"<<endl<<endl;
    }
    return 0;
}
           
上一篇: 對拍
下一篇: 對拍