【发布时间】:2019-03-15 13:10:51
【问题描述】:
include <stdio.h>
include <math.h>
int main()
{
int inches;
float feet, cm, yard, meter;
printf("Enter value <Unit: inches>:");
scanf("%d", &inches);
printf("Convert into *\n");
feet = inches/12;
cm = inches * 2.54;
yard = inches/36.0;
meter = cm/100;
printf("====================\n");
printf("feet\t:%6.2f\n", feet);
printf("cm\t\t:%6.2f\n", cm);
printf("yard\t:%6.2f\n", yard);
printf("====================\n \n");
printf("총 %dinches are %dm and %dcm.", inches, (int) round (cm/100), (int) cm%100);
}
抱歉,我不知道如何正确输入代码。我想将最后一个 "(int) cm%100" 部分向上舍入,因为 C 转换将其转换为整数并向下舍入。我将如何解决这个问题?它没有显示在帖子上,但我确实包含了 math.h 和 stdio.h
【问题讨论】:
-
抱歉,问题看错了,downvote 转换为 upvote。
-
没关系,会发生的哈哈
标签: c