首先先寫一個生成test.in的代碼,利用随機數生成測試資料。
#include <bits/stdc++.h>
using namespace std;
int main()
{
freopen("test.in","w",stdout);//設定 cout printf 這些輸出流都輸出到 test.in裡面去
for(int i=0;i<1e4;i++)
cout<<rand()%10000<<endl;//随機生成10000個數
return 0;
}
再根據你寫的代碼生成test.out
#include <bits/stdc++.h>
using namespace std;
int main()
{
freopen("test.in","r",stdin);//設定 cin scanf 這些輸入流都從 test.in中讀取
freopen("test.out","w",stdout);//設定 cout printf 這些輸出流都輸出到 test.out裡面去
//寫待測程式,即标程
}