【发布时间】:2014-03-30 22:29:45
【问题描述】:
我需要用科学计数法显示一个元素。 cout 位于几个循环内,设置科学计数法后,它会影响程序中的整个 cout。 如何切换回常规符号。
这是 cout 行:
cout << "Firing '" << fir << "' Time: " << time << " sec\nCorresponding altitude: " << scientific << alt << endl;
只有变量 alt 应该以科学计数法显示。
我添加了 cout.precision(2);和 cout
感谢您的帮助。
【问题讨论】:
-
你不能在 cout 行之前定义 cout.precision(2) 然后输出该行的一部分,然后改变精度 cout.precision(10) 和输出剩下的。