普通网友 2016-12-04 05:25 采纳率: 0%
浏览 866

求助C语言大神,我的这个程序错在哪了,如何改正!!

#include
//转化为2进制
void z2(int n)
{
if (n > 1)
{
z2(n / 2);
}
printf("%d", n%2);
}
void z21(long double f,int c)
{
float twice;
int tmp;
if (c == 0)
return ;
twice = f * 2;
tmp = (int)twice;
printf("%d", tmp);
z21(twice - tmp, --c);
}
void z211(int zhengshu, float xiaoshu)
{
// 输出整数部分
z2(zhengshu);
if (xiaoshu > 0.000001)
{
printf(".");
}
// 输出小数部分
z21(xiaoshu, 10);
}
void z8(int n)
{
if(n>7)
{
z8(n/8);
}
printf("%d",n%8);
}
void z81(long double f,int c)
{
double twice;
int tmp;
if(c==0)
return ;
twice=f*8;
tmp=(int)twice;
printf("%d",tmp);
z81(twice-tmp,--c);
}
void z811(int zhengshu,float xiaoshu)
{
z8(zhengshu);
if(xiaoshu>0.000001)
{
printf(".");
}
z81(xiaoshu,10);
}
char c1[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
void z16(int n)
{
if(n>15)
{
z16(n/16);
}
printf("%c",c1[n%16]);
}
void z161(long double f,int c)
{
long double twice;
int tmp;
if(c==0)
return ;
twice=f*16;
tmp=(int)twice;
printf("%c",c1[tmp]);
z161(twice-tmp,--c);
}
void z1611(int zhengshu,float xiaoshu)
{
z16(zhengshu);
if(xiaoshu>0.000001)
{
printf(".");
}
z161(xiaoshu,10);
}
void main()
{
float shu = 0;
int zhengshu = 0;
printf("请输入一个十进制数:");
scanf("%f", &shu);
if(shu < 0)
{
printf("-");
shu *= -1;
}
zhengshu = (int)shu;
shu -= zhengshu;
z211(zhengshu,shu);
printf("\n");
z811(zhengshu,shu);
printf("\n");
z1611(zhengshu,shu);
printf("\n");
}图片说明

这个程序输出的是第一张图,怎么改正成为第二张图啊,着急!

  • 写回答

2条回答 默认 最新

  • zqbnqsdsmd 2016-12-04 05:29
    关注

    别急,别急,阿弥陀佛

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题