与十进制数677等值的十六进制数是。。。??怎么算啊??
3个回答
2013-07-19
展开全部
#include <stdio.h>
void ba();
void er();
void shiliu();
int num[50];
int i,shu;
int count = 0;
void main()
{
int chioce;
do
{
printf("\n0.退出、1.十进制--二进制、2.十进制--八进制、3.十进制--十六进制\n");
printf("选择的功能:");
scanf("%d",&chioce);
switch (chioce)
{
case 1: er();
break;
case 2: ba();
break;
case 3: shiliu();
break;
}
} while ( !chioce == 0);
printf("退出\n");
printf("\n");
}
void er()
{
count = 0;
printf("请输入一个十进制的数:");
scanf("%d",&shu);
do
{
num[count] = shu%2;
shu = shu/2;
count++;
}while (shu!=0);
printf("转换为二进制为:");
for (i = count - 1;i >= 0;i--)
{
printf("%d",num[i]);
}
printf("\n");
}
void ba()
{
count = 0;
printf("请输入一个十进制的数:");
scanf("%d",&shu);
do
{
num[count] = shu%8;
shu = shu/8;
count++;
}while (shu!=0);
printf("转换为八进制为:");
for (i = count - 1;i >= 0;i--)
{
printf("%d",num[i]);
}
printf("\n");
}
void shiliu()
{
count = 0;
printf("请输入一个十进制的数:");
scanf("%d",&shu);
do
{
num[count] = shu%16;
shu = shu/16;
count++;
}while (shu!=0);
printf("转换为十六进制为:");
for (i = count - 1;i >= 0;i--)
{
switch (num[i])
{
case 10:printf("A");
break;
case 11:printf("B");
break;
case 12:printf("C");
break;
case 13:printf("D");
break;
case 14:printf("E");
break;
case 15:printf("F");
break;
default:printf("%d",num[i]);
}
}
printf("\n");
}
void ba();
void er();
void shiliu();
int num[50];
int i,shu;
int count = 0;
void main()
{
int chioce;
do
{
printf("\n0.退出、1.十进制--二进制、2.十进制--八进制、3.十进制--十六进制\n");
printf("选择的功能:");
scanf("%d",&chioce);
switch (chioce)
{
case 1: er();
break;
case 2: ba();
break;
case 3: shiliu();
break;
}
} while ( !chioce == 0);
printf("退出\n");
printf("\n");
}
void er()
{
count = 0;
printf("请输入一个十进制的数:");
scanf("%d",&shu);
do
{
num[count] = shu%2;
shu = shu/2;
count++;
}while (shu!=0);
printf("转换为二进制为:");
for (i = count - 1;i >= 0;i--)
{
printf("%d",num[i]);
}
printf("\n");
}
void ba()
{
count = 0;
printf("请输入一个十进制的数:");
scanf("%d",&shu);
do
{
num[count] = shu%8;
shu = shu/8;
count++;
}while (shu!=0);
printf("转换为八进制为:");
for (i = count - 1;i >= 0;i--)
{
printf("%d",num[i]);
}
printf("\n");
}
void shiliu()
{
count = 0;
printf("请输入一个十进制的数:");
scanf("%d",&shu);
do
{
num[count] = shu%16;
shu = shu/16;
count++;
}while (shu!=0);
printf("转换为十六进制为:");
for (i = count - 1;i >= 0;i--)
{
switch (num[i])
{
case 10:printf("A");
break;
case 11:printf("B");
break;
case 12:printf("C");
break;
case 13:printf("D");
break;
case 14:printf("E");
break;
case 15:printf("F");
break;
default:printf("%d",num[i]);
}
}
printf("\n");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询