float "变量";

cout<<fixed << setprecision("几位小数") <<"变量";

上为保留小数