题解 | #小麻烦,阻挡人前进的是麻烦而不是困难#
网购
http://www.nowcoder.com/practice/5d7dfd405e5f4e4fbfdff6862c46b751
#include<stdio.h>
int main()
{
double price = 0.0;
int month = 0;
int day = 0;
int flag = 0;
double cut = 1.0;
double last = 0.0;
scanf("%lf %d %d %d",&price,&month,&day,&flag);
if (month==11 && day==11)
{
cut = 0.7;
if(flag==1)
{
last = price*cut-50;
}
else
{
last = price*cut;
}
} else if (month==12 && day==12)
{
cut = 0.8;
if(flag==1)
{
last = price*cut-50;
}
else
{
last = price*cut;
}
}
else
{
last = price;
}
if(last<0.0)
printf("%.2lf\n",0.0);
else
printf("%.2lf\n",last);
return 0;
}
int main()
{
double price = 0.0;
int month = 0;
int day = 0;
int flag = 0;
double cut = 1.0;
double last = 0.0;
scanf("%lf %d %d %d",&price,&month,&day,&flag);
if (month==11 && day==11)
{
cut = 0.7;
if(flag==1)
{
last = price*cut-50;
}
else
{
last = price*cut;
}
} else if (month==12 && day==12)
{
cut = 0.8;
if(flag==1)
{
last = price*cut-50;
}
else
{
last = price*cut;
}
}
else
{
last = price;
}
if(last<0.0)
printf("%.2lf\n",0.0);
else
printf("%.2lf\n",last);
return 0;
}
查看19道真题和解析