生成0~1随机数 采用rand()函数生成 #define N 999 //精度为小数点后面3位srand((unsigned)time(NULL));//使得每次启动程序的随机数不同 rand() % (N + 1) / (float)(N + 1);