请问批量造数据的方法

灌水区

~~rand()~~
by Karl_Aurora @ 2020-02-28 10:35:50


@[我谔谔](/user/127284) 蟹蟹dalao但是可以给个例子吗 比如我想造P1001的10个数据
by __gcd @ 2020-02-28 10:37:40


@[一只大头](/user/149192) ```cpp ll chr(){return rand()&255;} ll llrand(){ll ret=0;F(i,1,7) ret=(ret<<8)|chr();return ret;} ll rand(ll l,ll r){return llrand()%(r-l+1)+l;} char str[100];FILE *f; int main() { F(i,1,20) { sprintf(str,"data%02d.in",i);f=fopen(str,"w"); int a,b;a=rand(1,1000);b=rand(1,1000); //随机生成输入数据 fprintf(f,"%d %d\n",a,b); //输出数据到输入文件 fclose(f); sprintf(str,"data%02d.out",i);f=fopen(str,"w"); fprintf(f,"hahah");fclose(f); //创建输入文件 sprintf(str,"sol.exe <xds%02d.in >xds%02d.out",i,i); system(str); //运行 std } return 0; } ```
by WYXkk @ 2020-02-28 10:39:32


@[一只大头](/user/149192) https://www.luogu.com.cn/paste/yil38g8v
by ieeqwq @ 2020-02-28 10:39:47


@[一只大头](/user/149192) freopen(s[i],"w",stdout); s[i]为"1.in","2.in","3.in",...不知道可不可以。
by xh39 @ 2020-02-28 10:40:54


@[我谔谔](/user/127284) @[WYXkk](/user/130151) 谢谢两位dalao
by __gcd @ 2020-02-28 10:43:52


```cpp #include<bits/stdc++.h> using namespace std; char str[100]; int main(){ srand(time(0)); int n=10;int m=10; for(int oo=1;oo<=10;oo++){ sprintf(str,"qaq%d.in",oo); freopen(str,"w",stdout); cout<<n<<" "<<m<<endl; for(int i=1;i<=n;i++) /// } } return 0; } ``` @[一只大头](/user/149192)
by BFqwq @ 2020-02-28 10:58:02


@[世界第一肥宅BF](/user/120074) 谢谢 ~~忘恩负义了这个简单多了~~
by __gcd @ 2020-02-28 10:58:45


你自己把要输出的数据补完,然后运行一次你的文件夹中就有10组数据 数据组数改 $oo$ 变量
by BFqwq @ 2020-02-28 10:58:53


@[世界第一肥宅BF](/user/120074) 但是std在哪里运行啊
by __gcd @ 2020-02-28 10:59:10


上一页 | 下一页