为什么编码是显示小数保留三位,而结果确实两位? 此前这个文件设计时输出小数点后两位 , 修改成下图样式 ,运行结果没变 !

#include
#include
using namespace std;
int main()
{
double a = 123.45665 , b = 3.1456 , c = -3214.67 ;
cout << setiosflags(ios::fixed) << setprecision(3) ;
cout << setw(10) << a << '\n'
<< setw(10) << b << '\n'
<< setw(10) << c << '\n' ;
return 0;
}


运行结果为
123.46
3.14
-3214.67

你是怎么运行程序的,通过IDE吗

#include <iostream>
#include <iomanip>

using namespace std;
int main()
{
double a = 123.45665 , b = 3.1456 , c = -3214.67 ;
cout << setiosflags(ios::fixed) << setprecision(3) ;
cout << setw(10) << a << '\n'
<< setw(10) << b << '\n'
<< setw(10) << c << '\n' ;
return 0;
}

结果正常,如下:

  123.457
    3.146
-3214.670