学术区人生地不熟
  • 板块灌水区
  • 楼主longxiaozhi
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/7/27 20:21
  • 上次更新2023/11/3 07:19:38
查看原帖
学术区人生地不熟
961067
longxiaozhi楼主2023/7/27 20:21

40分

http://bas.ssoier.cn:8086/index.php

邮局对邮寄包裹有如下规定:若包裹的重量超过 30 千克,不予邮寄,对可以邮寄的包裹每件收手续费 0.2 元,再加上根据下表按重量 x 计算的结果。

重量价格
x <= 100.80
10 < x <= 200.75
20 < x <= 300.7
请你编写一个程序,输入包裹重量,输出所需费用或"Fail"表示无法邮寄。
#include<bits/stdc++.h>
using namespace std;
int n;
double s = 0.2;
int main()
{
	scanf("%d",&n);
	if(n <= 10)
	{
		s = s + n * 0.80;
		printf("%.2lf",s);
	}
	else
	{
		if(n > 10 && n <= 20)
		{
			s = s + n * 0.75;
			printf("%.2lf",s);
		}
		else
		{
			if(n > 20 && n <= 30)
			{
				s = s + n * 0.70;
				printf("%.2lf",s);
			}
			else
			{
				printf("Fail");
			}
		}
	}
	return 0;
}

|

2023/7/27 20:21
加载中...