设为首页 加入收藏

TOP

10进制转2进制
2014-11-23 22:25:23 】 浏览:3763
Tags:进制

无聊写的,算法写的很糟,欢迎批评指正

#include
#include
using namespace std;

void Dec_Bin(int);

int main()
{
int num;
cout << "Please input a DEC number:";
cin >> num;
Dec_Bin(num);
cout << endl;
system("pause");
return 0;
}

void Dec_Bin(int num)
{
int temp[255], i = 0;
while(num > 0)
{
temp[i] = num % 2;
num = floor(num / 2);
i++;
}
cout << "Bin is:";
while(i > 0)
{
cout << temp[i-1];
i--;
}
cout << endl;
}

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇经典c编程 下一篇介绍python下wmi模块之二:得到本..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目