C Primer Plus第六版编程练习5.4
作者:互联网
新手欢迎指正
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-me;
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;
}
标签:feet,%.,5.4,int,Please,height,第六版,Plus,printf 来源: https://blog.csdn.net/qq_44832043/article/details/104570904