题解 | #网购#

网购

https://www.nowcoder.com/practice/5d7dfd405e5f4e4fbfdff6862c46b751

#include <stdio.h>

int main() 
{
	double price = 0.0;//价格
	int month = 0;//月
	int day = 0;//日
	int flag = 0;//是否有优惠卷
	//输入
	scanf("%lf %d %d %d", &price, &month, &day, &flag);
	//计算
	double sum = 0.0;//计算价格
	double cut = 0.0;//折扣
	if (month == 11 && day == 11) 
	{
		cut = 0.7;
		if (flag == 1) 
		{
			sum = price * cut - 50;
		}
		else 
		{
			sum = price * cut;
		}
	}
	else if (month == 12 && day == 12) 
	{
		cut = 0.8;
		if (flag == 1) 
		{
			sum = price * cut - 50;
		}
		else 
		{
			sum = price * cut;
		}
	}
	if (sum < 0.0) 
	{
		printf("%.2lf\n", 0.0);
	}
	else 
	{
		printf("%.2lf\n", sum);
	}
	return 0;
}

全部评论

相关推荐

05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务