叮滴答


私信TA

用户名:cdd1999

访问量:2881

签 名:

等  级
排  名 1189
经  验 3112
参赛次数 0
文章发表 5
年  龄 0
在职情况 学生
学  校 河南农业大学
专  业

  自我简介:

解题思路:

注意事项:

参考代码:


//写的有点麻烦,用的是笨方法


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 人评分

  评论区

  • «
  • »