C++ cout输出格式化(1)

来源:互联网 发布:android c语言开发 编辑:程序博客网 时间:2024/05/19 04:06

如何使用C++输出整数的十六进制形式的字符串。

#include <iostream>#include <iomanip>  // 操纵器头文件 (IO Manipulators)using namespace std;int main(){    int x = 90;    int y = 89;    int z = 45;    cout << setw(2) << setfill('0') << uppercase << hex << x << ", "        << y << ", "        << z << endl;} 

设置十六进制字符串输出 2字符对齐

原创粉丝点击