头文件:
#include<stdlib.h>
#include<time.h>
主程序:
srand((unsigned)time(NULL));
int randNumber1 = rand();
int randNumber2 = rand()%10;//取0~9范围内的随机数
程序运行结果:
头文件:
#include<stdlib.h>
#include<time.h>
主程序:
srand((unsigned)time(NULL));
int randNumber1 = rand();
int randNumber2 = rand()%10;//取0~9范围内的随机数
程序运行结果: