C++里面怎样控制输出格式?
来源:百度知道 编辑:UC知道 时间:2024/05/31 14:04:02
比如让5输出为5.00
#include "iostream.h"
#include "iomanip.h"
void main()
{
int a = 5;
cout << setiosflags(ios::fixed)<<setprecision(2)<<(float)a<<endl;
}
假设a等于5cout<<%.2f<<a<<endl cout<<%d<<a<<endlcout<<%m.nf<<a<<endlm表示整数,n表示小数位数你自己上网搜一下吧,几句话说不清楚的