随机数测试数据生成模板

 1 #include <bits/stdc++.h>
 2 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 3 #define _rep(i,a,b) for(int i = (a);i > b;i --)
 4 #define INF 0x3f3f3f3f
 5 #define MOD 1000000007
 6 typedef long long ll;
 7 using namespace std;
 8 
 9 int Myrand(int l,int r)
10 {
11     int num1 = rand() % r + 1;
12     int num2 = rand() % r + 1;
13     return num1-num2!=0?num1-num2:1;
14 }
15 int main()
16 {
17     freopen("creator3.in","w+",stdout);
18     srand(time(0));
19     int N = 12;
20     printf("%d\n",N);
21     _for(i,0,N-1)
22         printf("%d ",Myrand(-39,39));
23     printf("%d\n",Myrand(-39,39));
24     return 0;
25 }

 

posted @ 2019-08-27 23:30  Asurudo  阅读(265)  评论(0编辑  收藏  举报