前言
在出题时,数据当然是非常重要的,那么没有出过题的同学一定会好奇怎么生成一组组的好数据的……
当然了,数据的前提是你写好了std。
1. 手写
这种方法主要用于数据的量不大,比如说只有一两个数,如小凯的疑惑这种题目。
2. 使用Dev
这种方法主要用于机房,你不想装其他乱七八糟的软件时即可使用这种方法。下面给出一个极其基础的例子。
此代码用于生成9组a+b的数据,在C++11下编译通过,如果是旧的话要写为fout ((s+(char)(i+'0')+".in").data())
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
srand(time(0));
string s="a+b";
for(int i=1;i<=9;i++){
ofstream fout (s+(char)(i+'0')+".in");
fout<<rand()<<' '<<rand()<<endl;
ofstream fout2 ("tmp.txt");
fout2<<i<<endl;
system("std.exe < tmp.txt");
fout2.close();
system("del tmp.txt");
}
return 0;
}