fork download
  1.  
  2. // your code goes here#include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. int main()
  6. {
  7. // 设置随机数种子为当前时间
  8. srand(time(NULL));
  9. // 现在可以生成随机数了
  10. int randomNumber = rand()%10 + 1;
  11. printf("随机数为:%d\n",randomNumber);
  12. return 0;
  13. }
  14.  
  15.  
  16.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
随机数为:4