HzuWHF


私信TA

用户名:I7I08I9047

访问量:77351

签 名:

我RUN了

等  级
排  名 18
经  验 20556
参赛次数 13
文章发表 127
年  龄 3
在职情况 学生
学  校 贺州学院
专  业

  自我简介:

解题思路:
        

        不要打我!这题本来就不难,你肯定是嫌烦啦。


参考代码:

#include<iostream>
#include<cstring>
using namespace std;

    /* 返回最大的分数段 */
int Max(int A, int B, int C, int D, int E) {
	int Max = A;
	Max = Max > B ? Max : B;
	Max = Max > C ? Max : C;
	Max = Max > D ? Max : D;
	return Max > E ? Max : E;
}

int main() {
    /*    数据初始化     */
    
	int hash[101], num, temp, A, B, C, D, E;
	A = B = C = D = E = 0;
	memset(hash, 0, 101 * sizeof(int));
	
    /* 数据读入 */
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> temp; hash[temp]++;
	}
        
    /* 数据统计 */
	for (int i = 0; i < 101; i++) {
		if (i < 60)	    E += hash[i];
		else if (i < 70)  D += hash[i];
		else if (i < 80)  C += hash[i];
		else if (i < 90)  B += hash[i];
		else			  A += hash[i];
	}
	
	/* 取范围 */
	int max = Max(A, B, C, D, E), start, end;
	if (max == A)		{ start = 90, end = 100; }
	else if (max == B)	 { start = 80, end =  89; }
	else if (max == C)	 { start = 70, end =  79; }
	else if (max == D)	 { start = 60, end =  69; }
	else if (max == E)	 { start =  0, end =  59; }

	cout << A << ' ' << B << ' ' << C << ' ' << D;
	cout << ' ' << E << endl << max << endl;
	
	/* 输出分数 */
	while (end >= start) {
		while (hash[end]) {
			cout << end << ' ';
			hash[end]--;
		}
		end--;
	}
	return 0;
}


 

0.0分

0 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区