当前位置: 代码迷 >> C++ >> 非常简单的小疑点
  详细解决方案

非常简单的小疑点

热度:2620   发布时间:2013-02-26 00:00:00.0
非常简单的小问题
#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位小数输出。
  相关解决方案