首先先写一个生成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里面去
//写待测程序,即标程
}
本文介绍了一种使用C++生成测试输入文件(test.in)的方法,并演示了如何通过读取该文件生成对应的输出文件(test.out),适用于算法测试及代码验证。
&spm=1001.2101.3001.5002&articleId=72825443&d=1&t=3&u=5d80d773835b47618851482f439f8dac)
4021

被折叠的 条评论
为什么被折叠?



