要看你精确到几位我写毕族升了一个精确到0.01的供你参考#include#include#includeint main(){ float num; srand(time(NULL)); num = (rand()%100)*0.01;/*这里可以控穗数制精度,应该能看懂吧,这里是两位精度,如果你想精确到0.001,可以写成num = (rand()%1000)*0.001;*/ cout<<"手老The number is: "<}
1楼的说的非常正确