Skip to content

Instantly share code, notes, and snippets.

@cfrco
Created September 9, 2011 09:43
Show Gist options
  • Select an option

  • Save cfrco/1205849 to your computer and use it in GitHub Desktop.

Select an option

Save cfrco/1205849 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
// return _a ~_b random (include _b) and _a <= _b
#define RAND_INT(_a,_b) (rand()%(_b-_a+1) + _a)
#define LINE_MIN 50
#define LINE_MAX 150
#define PER_MIN 0 //1
#define PER_MAX 30
#define NUM_MIN 1
#define NUM_MAX 500
int main()
{
int i,j,le,ne;
srand(time(NULL)); //give rand a seed
//lines
le = RAND_INT(LINE_MIN,LINE_MAX);
for(i=0;i<le;++i)
{
//first
printf("%d",RAND_INT(NUM_MIN,NUM_MAX));
//per line
ne = RAND_INT(PER_MIN,PER_MAX);
for(j=0;j<ne;++j)
printf(" %d",RAND_INT(NUM_MIN,NUM_MAX));
putchar(10);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment