解题思路:
注意事项:
参考代码:
import java.util.Arrays;
import java.util.Scanner;
public class class01 {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int n=sc.nextInt();
int[][] st=new int[n][2];//用来存成绩和等级下标
int[] sr=new int[5];//用来存等级
for (int i = 0; i < st.length; i++) {
st[i][0]=sc.nextInt();
if (st[i][0]>=90&&st[i][0]<=100) {
sr[0]++;
st[i][1]=0;//给等级的下标
}
if (st[i][0]>=80&&st[i][0]<=89) {
sr[1]++;
st[i][1]=1;
}
if (st[i][0]>=70&&st[i][0]<=79) {
sr[2]++;
st[i][1]=2;
}
if (st[i][0]>=60&&st[i][0]<=69) {
sr[3]++;
st[i][1]=3;
}
if (st[i][0]>=0&&st[i][0]<=59) {
sr[4]++;
st[i][1]=4;
}
}
int max=0,index=0;
for (int i = 0; i < sr.length; i++) {
if (max<sr[i]) {//接受等级最多和下标
max=sr[i];
index=i;
}
System.out.print(sr[i]+" ");
}
System.out.println();
System.out.println(max);
//用于接受最多人的数据
int[]arr=new int[sr[index]];
int k=0;
for (int i = 0; i < st.length; i++) {
if (st[i][1]==index) {
arr[k++]=st[i][0];
}
}
//倒序
Arrays.sort(arr);
for (int i = arr.length-1; i >=0; i--) {
System.out.print(arr[i]+" ");
}
}
}
0.0分
2 人评分
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:749 |
简单的a+b (C语言代码)浏览:335 |
Cylinder (C语言描述+详细分析)浏览:3262 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:561 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:667 |
C二级辅导-计负均正 (C语言代码)浏览:480 |
1134题解(求分析)浏览:722 |
C二级辅导-分段函数 (C语言代码)浏览:739 |
母牛的故事 (C语言代码)浏览:476 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:819 |