解题思路:
注意事项:
参考代码:
//写的有点麻烦,用的是笨方法
import java.util.*;
public class Text_1500 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
String a1 = "";
String b1 = "";
String c1 = "";
String d1 = "";
String e1 = "";
for (int i = 0; i < arr.length; i++) {
if (arr[i] >= 90 && arr[i] <= 100) {
a++;
a1 = a1 + arr[i] + " ";
} else if (arr[i] >= 80 && arr[i] <= 89) {
b++;
b1 = b1 + arr[i] + " ";
} else if (arr[i] >= 70 && arr[i] <= 79) {
c++;
c1 = c1 + arr[i] + " ";
} else if (arr[i] >= 60 && arr[i] <= 69) {
d++;
d1 = d1 + arr[i] + " ";
} else if (arr[i] >= 0 && arr[i] <= 59) {
e++;
e1 = e1 + arr[i] + " ";
}
}
System.out.println(a + " " + b + " " + c + " " + d + " " + e);
if (a > b && a > c && a > d && a > e) {
print(a, a1);
} else if (b > a && b > c && b > d && b > e) {
print(b, b1);
} else if (c > a && c > b && c > d && c > e) {
print(c, c1);
} else if (d > a && d > b && d > c && d > e) {
print(d, d1);
} else if (e > b && e > c && e > d && e > a) {
print(e, e1);
}
}
public static int[] sort(String s) {
String[] arr = s.split(" ");
int[] newarr = new int[arr.length];
for (int i = 0; i < arr.length; i++) {
newarr[i] = Integer.parseInt(arr[i]);
}
Arrays.sort(newarr);
return newarr;
}
public static void print(int m, String n) {
System.out.println(m);
int[] newarr = sort(n);
for (int i = newarr.length - 1; i >= 0; i--) {
System.out.print(newarr[i] + " ");
}
}
}
0.0分
0 人评分
C语言考试练习题_保留字母 (C语言代码)浏览:733 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:773 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:287 |
A+B for Input-Output Practice (II) (C语言代码)浏览:1043 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:606 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:895 |
关于C语言变量位置的问题浏览:294 |
愚蠢的摄影师 (C++代码)浏览:980 |
输出九九乘法表 (C语言代码)浏览:1172 |
老王赛马 (C++代码)浏览:973 |