题解 | #网购#
网购
https://www.nowcoder.com/practice/5d7dfd405e5f4e4fbfdff6862c46b751
#include <stdio.h> int main() { float price = 0;//商品价格 int month = 0; int day = 0; int n = 0;//看看是否有优惠票 int dis = 0;//优惠票 scanf("%f", &price);//double的转移字符是%lf,float的是%f scanf("%d", &month); scanf("%d", &day); scanf("%d", &n); if (n == 1)//如果有就赋值一,把dis改为50 { dis = 50; } if ((month == 11 && day == 11) || (month == 12 && day == 12))//看看是否是双十一或者双十二 { if (month == 11)//双十一 { float a = price * 0.7 - dis; if (a < 0)//商家不可能倒贴钱,商品价格打完折后的价格比五十还少 { printf("0.00"); } else { printf("%.2f", a); } } else//双十二 { float b = price * 0.8 - dis; if (b < 0) { printf("0.00");//商家不可能倒贴钱 } else { printf("%.2f", b); } } } else { if (price - dis > 0) { printf("%.2f", price - dis); } else { printf("0.00");//商家不可能倒贴钱 } } return 0; }