1710819070


私信TA

用户名:1710819070

访问量:15411

签 名:

好好学习

等  级
排  名 323
经  验 5310
参赛次数 6
文章发表 21
年  龄 0
在职情况 学生
学  校 贺州学院
专  业 软件工程

  自我简介:

1+1+1+1+1+1=田

解题思路:

每个阶段都用数组保存,最后超过100万和不超过10万的都不保存(因为n是不确定的),这样看起来就不需要太复杂的输入了。

注意事项:

参考代码:

#include<iostream>

#include<algorithm>

#include<string.h>

#include<math.h>

using namespace std;

int main()

{

int i,j,n,sum=0;

int a[100]={100000*0.1,100000*0.075,200000*0.05,200000*0.03,400000*0.015};

cin>>n;     //  0         1          2            3           4

if(n>=0 && n<=100000) sum=n*0.1;

else if(n>100000 && n<=200000) sum=a[0]+(n-100000)*0.075;

else if(n>200000 && n<=400000) sum=a[0]+a[1]+(n-200000)*0.05;

else if(n>400000 && n<=600000) sum=a[0]+a[1]+a[2]+(n-400000)*0.03;

else

sum=(n-1000000)*0.01+a[0]+a[1]+a[2]+a[3]+a[4];

cout<<sum<<endl;

return 0;

}


 

0.0分

5 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#include<iostream>
using namespace std;
int main()
{
	int l;
	cin>>l;
	if(l<=100000)cout<<l*0.1<<endl;
	else if(l>100000&&l<=200000)cout<<100000*0.1+(l-100000)*0.075<<endl;
	else if(l>200000&&l<=400000)cout<<100000*0.1+100000*0.075+(l-200000)*0.05<<endl;
	else if(l>400000&&l<=600000)cout<<100000*0.1+100000*0.075+200000*0.05+(l-400000)*0.03<<endl;
	else if(l>600000&&l<=1000000)cout<<100000*0.1+100000*0.075+200000*0.05+200000*0.03+(l-600000)*0.015<<endl;
	else if(l>1000000)cout<<100000*0.1+100000*0.075+200000*0.05+200000*0.03+400000*0.015+(l-1000000)*0.01<<endl;
	return 0;
}
2020-02-25 23:46:39
头文件不用那么多吧,而且你也要用double吧
2019-10-25 15:45:10
int 要改为double
2019-10-17 21:25:24
为什么用到了那么多的头文件
2019-03-25 19:56:29
不错的数组保存固定值法,学到了,蟹蟹~~~~
2018-12-20 21:47:23
  • «
  • 1
  • »