#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
float x = 20, y = -400.00;
cout << x << ' ' << y << endl;
cout.setf(ios::showpoint);
cout << x << ' ' << y << endl;
cout.unsetf(ios::showpoint);
cout.setf(ios::scientific);
cout << x << ' ' << y << endl;
cout.setf(ios::fixed);
cout << x << ' ' << y << endl;
}
代碼如上
輸出如下
20 -400
20.0000 -400.000
2.000000e+01 -4.000000e+02
0x1.4000000000000p+4 -0x1.9000000000000p+8
代碼和書上一樣,為什么我的輸出和我的書上不一樣
書上的輸出結果:
20 -400
20.0000 -400.000
2.000000e+001 -4.000000e+002
20 -400
為什么我最后的輸出是很奇怪的東西,我用的是vs2019
cout.unsetf(ios::showpoint);這個不是消除設定格式嗎?為什么我的輸出還是有很多無效0,不應該是整數嗎。。。那個第四個輸出結果里面的p是什么東西,為什么是十六進制的
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/283240.html
標籤:新手樂園
上一篇:C++的解構式的繼承