rand生成随机值,需要在主函数中调用:
srand((unsigned) time( NULL));
并引头文件#include< stdlib> # include<time.h>
引申:int x= rand()%row
int y= rand(()%col
%(模)上几,那么随机数的范围就是0-几
rand生成随机值,需要在主函数中调用:
srand((unsigned) time( NULL));
并引头文件#include< stdlib> # include<time.h>
引申:int x= rand()%row
int y= rand(()%col
%(模)上几,那么随机数的范围就是0-几