解题思路:
注意事项:
参考代码:
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++代码)浏览:1091 |
【亲和数】 (C语言代码)浏览:855 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:377 |
C语言考试练习题_排列 (C语言代码)浏览:719 |
2005年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:582 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:587 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:879 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:901 |
模拟计算器 (C++代码)浏览:800 |
1071题解浏览:484 |