求一定范围随机数

    技术2022-05-11  98

    #include <stdio.h>#include <stdlib.h>#include <time.h>int main(){  int a[] = { 2, 4, 6, 8, 10 };  const int NUM = sizeof(a) / sizeof(*a);

      srand( time(0) );  printf( "%d/n", a[rand() % NUM] );}

    收获 

    1 获得数组的长度

    2 范围随机数


    最新回复(0)