#include <stdio.h>
float count_discount(int x, float y,float pay)
{
float sum;
if (pay<200)
{
sum = y * 0.3;// 每升优惠3毛
if (x == 5) // 星期五每升额外优惠1毛
sum += y * 0.1;
}
else
{
y = y - (200 / 8.38);
sum = y * 0.3;// 每升优惠3毛
if (x == 5) // 星期五每升额外优惠1毛
sum += y * 0.1;
}
sum = (int)(sum*100.0 + 0.5) / 100.0;
return sum;
}
float coupondiscount(float a)
{
if (a>200)
{
return 20;
}
else
{
return 0;
}
}
int main()
{
int t, x;
float y;
float pay, discount;
scanf("%d", &t);
while (t--)
{
scanf("%d", &x);
scanf("%f", &y);
pay =(8.38 * y);
discount = count_discount(x, y,pay);
if (pay >= 200)
pay -= 20;
pay = pay - discount;
printf("Order amount: %.2f\n", (int)(8.38 * y*100.0+0.5)/100.0);
printf("E-coupon discount amount: %.2f\n", coupondiscount(8.38 * y));
printf("Discount amount: %.2f\nPayment amount: %.2f\n", discount, (int)(pay*100.0 + 0.5) / 100.0);
}
return 0;
}
总是部分正确,不知道错在哪里\(◎o◎)/!大家看看能不能改改?是逻辑上的问题,还是精度的问题