4elist1714.cpp
来自「《21天学通C++》附盘的原代码。书上的每个例子在这里都有相应的C语言程序。」· C++ 代码 · 共 33 行
CPP
33 行
// Listing 17.14 - Using setf
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int number = 185;
cout << "The number is " << number << endl;
cout << "The number is " << hex << number << endl;
cout.setf(ios::showbase);
cout << "The number is " << hex << number << endl;
cout << "The number is " ;
cout.width(10);
cout << hex << number << endl;
cout << "The number is " ;
cout.width(10);
cout.setf(ios::left);
cout << hex << number << endl;
cout << "The number is " ;
cout.width(10);
cout.setf(ios::internal);
cout << hex << number << endl;
cout << "The number is:" << setw(10) << hex << number << endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?