尤果无圣光图片你懂的:2编程实现输入一个正整数,输出其对应的二进制数和十六进制数,要求轮换过程用自编函数来实现。

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 06:31:33
希望大家帮帮忙,不胜感激!!

这个程序只能转化成1到16进制数
#include <stdio.h>
void main()
{
long m;
int i=0,d,n,a[50],b[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

printf("please input the munber:\n");
scanf("%ld",&m);

printf("please input the base:\n");
scanf("%d",&n);

do{a[i]=m%n;i++;}while((m/=n)!=0);

printf("the new number is:\n");

for(--i;i>=0;i--)
{d=a[i];printf("%c ",b[d]);
}
printf("\n");
}

我也是刚刚学C,还请高手多多指教!!在VC上已经运行成功!

送你四个字:太不讲就!!!以后都不会再帮你!