Skip to content

Instantly share code, notes, and snippets.

@a1exlism
Created May 17, 2019 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1exlism/b025356fd0560a7abac3c2535079b81c to your computer and use it in GitHub Desktop.
Save a1exlism/b025356fd0560a7abac3c2535079b81c to your computer and use it in GitHub Desktop.
/*
* 生成在[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