// C++_test1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
// using namespace std;
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main() {
int n = 0;
unsigned short test_num = 0;
unsigned mask = 0x8000;
cout << "请输入一个数:" << endl;
cin >> test_num;
while (n++ < sizeof(test_num) * 8) {
cout << ((test_num&mask) != 0);
mask = mask >> 1;
if (n % 4 == 0) {
cout << " ";
}
}
cout << endl;
//用掉最后的回车
cin.ignore();
//暂停,供用户按下enter
// system("pause");
cin.ignore();
return 0;
}
C++2
最新推荐文章于 2024-03-15 08:26:26 发布