题解 | #网购#
网购
http://www.nowcoder.com/practice/5d7dfd405e5f4e4fbfdff6862c46b751
#include<stdio.h>
int main() {
float val;
int month, day, a;
scanf("%f %d %d %d", &val, &month, &day, &a);
if (month + day == 22 || month + day == 24) { //判断日期是否在双11或双12
if (month + day == 22) val *= 0.7; //双11打7折
if (month + day == 24) val *= 0.8; //双12打8折
if (a == 1) val -= 50; //优惠卷减50
if (val < 0) val = 0.00; //实际花钱小于0时,val赋值0
printf("%.2f", val); //输出优惠后的金额
} else printf("%.2f", val); //输出无任何优惠的金额
return 0;
}
int main() {
float val;
int month, day, a;
scanf("%f %d %d %d", &val, &month, &day, &a);
if (month + day == 22 || month + day == 24) { //判断日期是否在双11或双12
if (month + day == 22) val *= 0.7; //双11打7折
if (month + day == 24) val *= 0.8; //双12打8折
if (a == 1) val -= 50; //优惠卷减50
if (val < 0) val = 0.00; //实际花钱小于0时,val赋值0
printf("%.2f", val); //输出优惠后的金额
} else printf("%.2f", val); //输出无任何优惠的金额
return 0;
}