概述
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int count;
int x,i,j;
int a[20];
cout << "请输入一个十进制整数:"<<endl;
cin >> x;
for(count=0;count<=20;count++)
{
i = x / 2;
j = x % 2;
a[count] = j;
x = i;
}
cout << "转换成二进制后:" << endl;
for (count=20; count >= 0; count--)
cout << a[count];
cout << endl;
return 0;
}

最后
以上就是活力大侠为你收集整理的实验2:十进制转二进制 (使用数组)(补)的全部内容,希望文章能够帮你解决实验2:十进制转二进制 (使用数组)(补)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复