Created
May 17, 2019 09:53
-
-
Save a1exlism/b025356fd0560a7abac3c2535079b81c 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
/* | |
* 生成在[a, b]范围内的随机数据 | |
* Random numbers in the range of [a,b] | |
*/ | |
#include <cstdio> | |
#include <cstdlib> | |
#include <ctime> | |
const int MAXN = 1000; | |
int main() { | |
int arr[MAXN]; | |
int a, b; | |
a = 10, b = 100; | |
srand((unsigned)time(NULL)); | |
for(int i = 0; i < 50; i++) { | |
arr[i] = rand() % (b - a + 1) + a; | |
printf("%d\n", arr[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment