源代码:编辑器是Sublime Text 2
/* rhodium.c -- 用金属铑衡量您的体重 */
#include <stdio.h>
int main(void)
{
float weight, value;
printf("Are you worth your weight in rhodium?\n");
printf("Let's check it out.\n");
printf("Please enter your weight in pounds:150\n");
/* 从用户处获取输入 */
scanf ("%f", &weight);
/* 假设铑为每盎司770美元 */
/* 14.5833把常衡制的英镑转换为金衡制的盎司 */
value = 770 * weight * 14.5833;
printf("Your weight in rhodium is worth $%.2f\n", value);
printf("You are easily worth that! If rhodium prices drop,\n");
printf("eat more to maintain your value.\n");
return 0;
}
打印的结果:
Are you worth your weight in rhodium?
Let's check it out.
Please enter your weight in pounds:150
Your weight in rhodium is worth $0.00
You are easily worth that! If rhodium prices drop,
eat more to maintain your value.
$0.00应该是1684371.12
这一句,你是要做乘法运算?如果是,少了一个乘号(*)。
还有,你最好把你预期的结果说说。这个程序看起来一堆,实际上就是一个乘法运算!
请看运行情况:

这是直接拷过来编译执行的。
刚才看了你的输出,发现很奇怪的两点:1.你没有输入值,150是通过printf函数输出到控制台的;2.不知道你在scanf时怎么继续的,因为:(直接敲回车的情况)

直接敲回车是得不到输入的,我是通过Ctrl+C来强制退出的。