C++怎样输出十六进制数?

如题所述

#include <iostream>
#include <iomanip>//不要忘记包含此头文件
using namespace std;
int main()
{
int a;
cout<<"input a:";
cin>>a;
cout<<"hex:"<<hex<<a<<endl; //以十六进制形式输出整数
return 0;
}

运行程序后,例如输入34(十进制)运行结果如下:
input a:34 (输入a的值)
hex:22 (十六进制形式)
温馨提示:答案为网友推荐,仅供参考
相似回答