整體:ios
對拍是一種適用於全部選手的一種驗證錯誤的方法,能夠用這種方法來實現錯誤與否。windows
可分爲4個源代碼。spa
咱們用個A+Bproblem舉例code
本身的代碼:blog
#include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; }
暴力的代碼:ci
#include<iostream> using namespace std; int main() { int a,b,c; cin>>a>>b; c=a+b; cout<<c; }
接下來是隨機數生成器io
#include <ctime> #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main() { srand(time(0)); int a = rand()%0217; int b = rand()%1112; printf("%d %d",a,b); return 0; }
最後是對拍程序:class
#include <windows.h> #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main() { int T = 1000; while(T--) { system("randdata > try.in"); system("try1 < try.in > try1.out"); system("try2 < try.in > try2.out"); if(system("fc try1.out try2.out")) break; } system("pause"); return 0; }