📄 cpptemplate.cpp
字号:
//=====================================
// title: 十进制转化为二进制
// author: cjj
// date: 2007-10-09
/* Description:
*/
//=====================================
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
for(int n; cin>>n;)
{
if(n==0)
{
cout<<setw(11)<<right<<"0-->0\n";
continue;
}
string s;
for(int a=n; a;)
{
s+=(a%2?'1':'0');
a/=2;
}
reverse(s.begin(), s.end());
cout<<setw(11)<<right<<n<<"-->"<<(n<0?"-":"")<<s<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -