> 其他 >
求高手解决一下下面的问题?
#include
int main(void)
{
const double unit_price = 3.50;
int quantity = 0;
printf("Enter the number that you want to buy:");
scanf(" %d", &quantity);

double total = 0.0;
if(quantity > 10)
 total = quantity*unit_price*0.95;
else
total = quantity*unit_price;
printf("The price for %d is $%.2f\n", quantity, total);
return 0;
}
这个程序输不出来,求解?
在编译时出现错误,我觉的没有错误呀!但是显示错误,不知道为什么
人气:408 ℃ 时间:2020-05-20 07:23:01
解答
C的话,把double total = 0.0;放到printf前面去,C只能在程序开头声明,我放在开头,可以运行
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版