#include<stdio.h>
int main(void)
{
float weight;
float value;
printf("Are you worth your weight in rhodium?\n");
printf("Let's check it out\n");
printf("please enter your weight in pounds:");
scanf("%f",&weight);
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("est more to maintain your value.\n");
return 0;
}
在这个东西里面的
printf("Your weight in rhodium is worth $%.2f.\n",value);
。。其中 $%.2f 求详解。。
------解决方案--------------------------------------------------------
在C语言中用%m.n加数据类型,表示以某种数据类型且宽度为M小数点后保留N位小数输出。