运行 ❯
获取您的
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 Spaces
#include <iostream> #include <iomanip> using namespace std; int main() { // Booleans cout << "Booleans\n"; cout << false << "\n"; cout << boolalpha << false << "\n"; // Hexadecimal and octal numbers cout << "\nHexadecimal and octal numbers\n"; int myInt = 14; cout << dec << myInt << "\n"; cout << hex << myInt << "\n"; cout << oct << myInt << "\n"; cout << showbase << uppercase; cout << hex << myInt << "\n"; cout << oct << myInt << "\n"; cout << dec; // Floating point numbers cout << "\nFloating point numbers\n"; float myFloat = 19.99; cout << myFloat << "\n"; cout << showpos << showpoint << 12345.0 << "\n"; cout << noshowpos << noshowpoint; cout << fixed << myFloat << "\n"; cout << scientific << myFloat << "\n"; // Alignment cout << "\nAlignment\n"; cout << setw(10) << left << "Left" << "\n"; cout << setw(10) << right << "Right" << "\n"; cout << setw(10) << internal << -12345 << " (Internal)\n"; return 0; }
布尔值
0
false
十六进制和八进制数字
14
e
16
0XE
016
浮点数
19.99
+12345.0
19.990000
1.999000E+01
对齐
左
右
- 12345 (内部)