CCF CSP攻克之路 —— 2016_12

1:中间数(100)

1.1 题目

在这里插入图片描述

1.2 代码与解答

#include<bits/stdc++.h>
using namespace std;
int db[1005]={};
int num[1005]={};

int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>db[i];
		num[db[i]]++;
	}
	for(int i=1;i<1005;i++)
	{
		sum += num[i-1];
		if(sum == n - sum - num[i]) 
		{
			for(int j=0;j<n;j++)
			{
				if(db[j]==i) 
				{
					cout<<i;
					goto here;
				}
			}
		}
		else if(i==1004) cout<<-1;
	}
	here:
    return 0;
}

2: 工资计算(100)

2.1 题目

在这里插入图片描述

2.2 代码与解答

#include<bits/stdc++.h>
using namespace std;
int main()
{
	float y,x;
	cin>>y;
	if(y<=3500) cout<<y;
	else if(y>3500&&y<=4955)
	{
		x = (y-105)/0.97;
		cout<<x;
	}
	else if(y>4955&&y<=7655)
	{
		x = (y-455)/0.9;
		cout<<x;
	}
	else if(y>7655&&y<=11255)
	{
		x = (y-1255)/0.8;
		cout<<x;
	}
	else if(y>11255&&y<=30755)
	{
		x = (y-1880)/0.75;
		cout<<x;
	}
	else if(y>30755&&y<=44755)
	{
		x = (y-3805)/0.7;
		cout<<x;
	}
	else if(y>44755&&y<=61005)
	{
		x = (y-6730)/0.65;
		cout<<x;
	}
	else if(y>61005)
	{
		x = (y-15080)/0.55;
		cout<<x;
	}
    return 0;
}

3: 权限查询

3.1 题目

在这里插入图片描述

3.2 代码与解答




4: 压缩编码

4.1 题目

在这里插入图片描述

4.2 代码与解答




5: 卡牌游戏

5.1 题目

在这里插入图片描述

5.2 代码与解答




发布了27 篇原创文章 · 获赞 6 · 访问量 525

猜你喜欢

转载自blog.csdn.net/qq_43246110/article/details/104288094