首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

非常简单的小疑点

2013-02-19 
非常简单的小问题#includestdio.hint main(void){float weightfloat valueprintf(Are you worth your

非常简单的小问题
#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位小数输出。

热点排行