#include<bits/stdc++.h>
using namespace std;
int main()
{
int x = 42;
cout<< x <<endl;//十进制
cout<< oct << showbase << x << endl;// oct指定以八进制输出,showbase指定 显示前导符0
cout<< hex << x <<endl;// hex指定以十六进制输出,显示前导符 0x
cout << resetiosflags(ios_base::basefield); // 恢复默认输入输出格式控制(需 要包含头文件iomanip)
bool ans = true;
cout << ans << endl; // 默认,布尔型变量以整数形式输出
cout << boolalpha << ans << endl; // 以布尔值形式输出
system("pause");
}
整数的不同进制输出 布尔型输出
最新推荐文章于 2023-04-26 13:29:31 发布