cpptemplate.cpp

来自「整数内码的显示方法」· C++ 代码 · 共 28 行

CPP
28
字号
//=====================================
// title: 整数内码
// author: cjj
// date: 2007-10-09
/* Description: 

*/
//=====================================
#include <iostream>
using namespace std;

int main()
{
	//for循环读入
	//for循环移位
	//对当前位进行输出(从高到低)
	//输出回车
	for (int n; cin >> n;)
	{
		for (int i = 31; i >= 0; i--)
		{
			//输出当前那个位上的数,0或者1
			cout << (n & (1 << i) ? 1 : 0);
		}
		cout << "  " << n << endl;
	}
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?