double cost; cout<<setiosflags(ios::fixed)<<setprecision(1)<<cost;//引用头文件#include<iomanip> 参考博客: https://www.cnblogs.com/stacktrace/p/5142470.html