C Primer Plus第六版编程练习5.4

可紊 提交于 2020-02-29 12:17:19

新手欢迎指正
5.4
#include <stdio.h>
#define FEET 2.54
#define INCH 30.48
int main(void)
{
float h=0,inch=0;
int feet=0;
printf(“Please enter a height in centimeters(<=0 to quit):\n”);
scanf("%f",&h);
while(h>0)
{
feet=(int)(h/INCH);
inch=(h-feet*INCH)/FEET;
printf("%.1f cm=%d feet,%.1f inches\n",h,feet,inch);
printf(“Please enter a height in centimeters:\n”);
scanf("%f",&h);
}

/float a,b,c,d,f=0;
printf(“Please enter a height in centimeters:\n”);
scanf("%f",&a);
while ( a>0){
const int m=12;
int e;
b=a/2.54;
c=b/m;
printf("%f\n",c);
e=(int)c;
printf("%d\n",e);
d=b-m
e;
f=
printf("%.1f cm=%d feet,%.1f inches\n",a,e,d);
printf(“Please enter a height in centimeters:\n”);
scanf("%f",&a);
}*/
printf(“bye\n”);
return 0;
}

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!