c++ 随机生成0到19之间的整数

c++ 随机生成0到19之间的整数

第1个回答  2017-12-28
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
main( )
{
  int i;
  srand((unsigned)time(NULL));
  printf( "%d\n", rand() * 19 + 1);
}

本回答被网友采纳
第2个回答  2017-12-27
rand()%20
相似回答