Created
September 9, 2011 09:43
-
-
Save cfrco/1205849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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