a1exlism
5/17/2019 - 9:53 AM

random_numbers

/* 
 * 生成在[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;
}