ACM生成数据的方法

首先先写一个生成test.in的代码,利用随机数生成测试数据。

 
  1. #include <bits/stdc++.h>

  2. using namespace std;

  3. int main()

  4. {

  5. freopen("test.in","w",stdout);//设置 cout printf 这些输出流都输出到 test.in里面去

  6. for(int i=0;i<1e4;i++)

  7. cout<<rand()%10000<<endl;//随机生成10000个数

  8. return 0;

  9. }


 

再根据你写的代码生成test.out

 
  1. #include <bits/stdc++.h>

  2. using namespace std;

  3. int main()

  4. {

  5. freopen("test.in","r",stdin);//设置 cin scanf 这些输入流都从 test.in中读取

  6. freopen("test.out","w",stdout);//设置 cout printf 这些输出流都输出到 test.out里面去

  7. //写待测程序,即标程

  8. }

猜你喜欢

转载自blog.csdn.net/I_O_fly/article/details/81416203