您的位置:首页 > 其它

ACM题目测试数据生成方法(个人经验)

2017-05-31 23:29 501 查看
首先先写一个生成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里面去
//写待测程序,即标程
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: