|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#define FANQIE 3.7
#define JIELAN 7
#define XIQIN 1.3
#define KONGXINCAI 8
#define YANGCONG 2.4
#define YOUCAI 9
#define HUANGGUA 6.3
#define BAILUOBO 0.5
int main()
{
float price;
price = (2 * FANQIE + KONGXINCAI + YOUCAI) * 0.5; // 1斤 == 0.5公斤
printf("小明需要支付%.2f元\n", price);
price = (3 * XIQIN + 0.5 * YANGCONG + 5 * HUANGGUA) * 0.5;
printf("小红需要支付%.2f元\n", price);
price = (10 * HUANGGUA + 20 * BAILUOBO) * 0.5;
printf("小甲鱼需要支付%.2f元\n", price);
return 0;
}
可以用其他单词或者短语来替换price,比如cost、expense、total等等。以下是代码示例:
- #include <stdio.h>
- #define FANQIE 3.7
- #define JIELAN 7
- #define XIQIN 1.3
- #define KONGXINCAI 8
- #define YANGCONG 2.4
- #define YOUCAI 9
- #define HUANGGUA 6.3
- #define BAILUOBO 0.5
- int main()
- {
- float cost;
- cost = (2 * FANQIE + KONGXINCAI + YOUCAI) * 0.5; // 1斤 == 0.5公斤
- printf("小明需要支付%.2f元\n", cost);
- float expense;
- expense = (3 * XIQIN + 0.5 * YANGCONG + 5 * HUANGGUA) * 0.5;
- printf("小红需要支付%.2f元\n", expense);
- float total;
- total = (10 * HUANGGUA + 20 * BAILUOBO) * 0.5;
- printf("小甲鱼需要支付%.2f元\n", total);
- return 0;
- }
复制代码
求最佳答案
|
|