10进制转2进制
无聊写的,算法写的很糟,欢迎批评指正
#include <iostream>
#include <cmath>
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语言 ,