创建文件
首先,找到你想放数据的位置,创建一个新的文件夹,命名为ACM。
首先,打开你的编译器,我这里用的是codeblocks,你们用DEV也可以,点击New file选定Project
然后选中
继续
我这里命名为hhh,位置是D:\CodeSpace\C
然后
获得进程:
造数据
我们把这个代码复制过去:
#include <bits/stdc++.h>
using namespace std;
int random(int l,int r){
return (long long)rand()*rand()%(r-l+1)+l;
}
int main()
{
srand(int(time(0)));//加上这个才能真正产生随机数
for(int i = 1; i <= 10; i ++){
string fileName = "";
string c = to_string(i);
fileName += c;
fileName += ".in";
freopen(fileName.c_str(), "w", stdout);
//下面写要生成的数据
fclose(stdout);
}
return 0;
}
效果:
然后写我们的数据
例如,我们要造数据,a,b,范围是1~1e8
然后跑代码
我们来看看,文件夹hhh,已经出现了10组输入文件
你们根据你们的需要写输入数据就好
下面是输出
输出数据
复制过去:
#include <bits/stdc++.h>
using namespace std;
void solve(){
//这里放自己程序的主函数
//自己程序的其他函数,直接写在其他地方就行了
}
int main(void)
{
for(int i = 1; i <= 10; i ++)
{
string fileName = "";
string c = to_string(i);//确定对应的标号
fileName += c;
fileName += ".in";
freopen(fileName.c_str(), "r", stdin);
string fileNameout = "";
string s = to_string(i);
fileNameout += s;
fileNameout += ".out";
freopen(fileNameout.c_str(), "w", stdout);
solve();
}
fclose(stdin);
fclose(stdout);
return 0;
}
效果:
写自己的运行代码,这里例如,a+b
运行,出现了输出的十个文件
将十个文件打包压缩就好啦!
你们一定没有问题了对吧,拜拜~