【发布时间】:2011-09-27 10:44:30
【问题描述】:
#include <stdio.h>
#include <math.h>
int main (void)
{
float inches;
printf("Enter the number of inches\n");
scanf("%f\n",&inches);
float feet;
float cm;
float yards;
float meter;
feet = 12 * inches;
cm = 2.54 * inches;
yards = 36 * inches;
meter = 39.37 * inches;
printf("Amount in feet: %f\n", &feet);
printf("Amount in cm: %f\n", &cm);
printf("Amount in yards: %f\n", &yards);
printf("Amount in meters: %f\n", &meter);
getchar();
return 0;
}
我正在使用 Dev c++
是我正在用 C 语言处理的问题吗?基本上以英寸为单位输入一个数字,然后以厘米、码、米和英尺为单位打印数量。这给了我 0.0000 或其他所有人的东西,或者实际上是时间到了。我无法保持屏幕打开,我认为这是 getchar() 的目的,但我一定是弄错了。任何帮助都很棒。谢谢!
编辑 1
如果我把东西放进去,让 dev c++ 留在屏幕上而不是关闭呢?当屏幕弹出时,我还必须输入 2 个值才能返回任何内容?为什么??
【问题讨论】:
-
其他人已经解决了您的问题,但作为旁注:
feet = inches / 12.0; yards = inches / 36.0; meters = inches / 39.37;