頭文件#include<iomanip>
1.需要補零
cout.setf(ios::fixed);
cout<<fixed<<setprecision(需要精確到小數點后幾位)<<ans<<endl;
2.不需補零
(1)末尾零被省略
cout<<setprecision(需要精確到小數點后幾位)<<ans<<endl;
(2)取消設置fixed
cout.unsetf(ios::fixed);
cout<<setprecision(需要精確到小數點后幾位)<<ans<<endl;