|
发表于 2021-11-5 13:28:02
|
显示全部楼层
本帖最后由 jackz007 于 2021-11-5 13:57 编辑
有两处错误:
float price ; // 行末添加分号 ;
printf=("小甲鱼需要支付的钱为%.2f元\n", price) ; // 去掉 print 和 () 之间的等号 =
下面是改好的代码:
- #include <stdio.h>
- #define FANQIE 3.7
- #define QINAN 7
- #define XIQIN 1.3
- #define KONGXINCAI 8
- #define YANGCONG 2.4
- #define FANSIE 9
- #define HUANGGUA 6.3
- #define BAILUOBO 0.5
- int main()
- {
- float price ;
- price=(2*FANQIE+KONGXINCAI)*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 ;
- }
复制代码
编译、运行实况:
- D:\00.Excise\C>g++ -o x x.c
- D:\00.Excise\C>x
- 小明需要支付的钱为7.70元
- 小红需要支付的钱为18.30元
- 小甲鱼需要支付的钱为36.50元
- D:\00.Excise\C>
复制代码 、 |
|