#include <stdio.h>
int main()
{
int Type,a,b[10],i=0,c=0;
printf("请输入转换类型,1:十进制转二进制;2:十进制转八进制;3:十进制转化为十六进制\n");
scanf("%d",&Type);
printf("请输入原数据\n");
scanf("%d",&a);
switch(Type)
{
case 1:
while(a!=0)
{
b[i]=a%2;
a/=2;
i++;
}
printf("二进制为:");
i--;
for(;i>=0;i--)
printf("%d",b[i]);
printf("\n");
break;
case 2:
while(a!=0)
{
b[i]=a%8;
a/=8;
i++;
}
printf("八进制为:");
i--;
for(;i>=0;i--)
printf("%d",b[i]);
printf("\n");