c语言编程 float p,程序清单3.1_rhodium.c程序_《C Primer Plus》P32

// rhodium.cpp : 定义控制台应用程序的入口点。

//

/* rhodium.c -- 用金属铑衡量您的的体重 */

/*

时间:2018年06月02日 21:26:34

代码:程序清单3.1_rhodium.c程序_《C Primer Plus》P32

目的:初识浮点小数变量类型 float;基本的数学换算,英镑转换成盎司;

*/

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])

{

float weight;    /* 用户的体重 */

float value;    /* 相等重量的铑的价值 */

/* worth(等值的)/thodium(金属:铑) */

printf("Are you worth your weight in rhodium?\n");

printf("Let's check it out.\n");    /* check it out(一探究竟) */

printf("Please enter your weight in pounds: ");    /* pound(英镑) */

/* 从用户处获取输入 */

scanf("%f", &weight);

/* 假设铑为每盎司 770 美元 */

/* 14.5833 把常衡制的英镑转换为金衡制的盎司 */

value = 770 * weight * 14.5833;

printf("Your weight in rhodium is worth $%.2f.\n", value); /* %.2f(意为保留2位小数)*/

printf("Your are easily worth that! If rhodium prices drop. \n");

printf("eat more to maintain your value. \n");

getchar();

getchar();

return 0;

}

/*

在VS2010中运行结果:

--------------------------------------------------

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 $1684371.13.

Your are easily worth that! If rhodium prices drop.

eat more to maintain your value.

--------------------------------------------------

译文如下:

你是否值得你在铑上的体重?

让我们来看看。

请输入你的体重,以磅为单位:150

你的铑重量值为1684371.13美元。

你很容易就是值得的! 如果铑价格下跌。

多吃东西来保持你的价值。

--------------------------------------------------

*/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值