c++中控制double类型变量小数点后0的个数为2 #include<iomanip> cout<<setprecision(2)<<setiosflags(ios::fixed)<<num<<endl;