zoukankan      html  css  js  c++  java
  • java.util. Arrays.sort(scores);

    import java.util.*;
    public class ArraySortScore {
        
        //完成 main 方法
        public static void main(String[] args) {
            
            
            int counter=0;
            int[] scores=new int[]{89 , -23 , 64 , 91 , 119 , 52 , 73};
            SortScore(scores);
            int index=0;
            while(index<scores.length)
            {
                System.out.println(scores[index]);
                index+=1;
            }
            System.out.println("考试成绩的前三名为:");
            index=0;
            while(index<scores.length)
            {
                if(scores[index]>=0 && scores[index]<=100)
                {
                    System.out.println(scores[index]);
                    counter+=1;
                    if(counter==3)
                        break;
                }
                index+=1;
            }
            
        }
        
        //定义方法完成成绩排序并输出前三名的功能
        public static void SortScore(int[] scores)
        {
           Arrays.sort(scores);
        }
        
        
        
        
        
        
        
        
        
    }
    ---------- java ----------
    -23
    52
    64
    73
    89
    91
    119
    考试成绩的前三名为:
    52
    64
    73
    
    Output completed (0 sec consumed) - Normal Termination
  • 相关阅读:
    复利计算-做汉堡,结对2.0-复利计算再升级
    java集合
    java 封装,继承,多态基础
    购物车
    ajax
    演示
    实验四
    实验三
    构建之法6-7章读后感
    作业调度模拟程序
  • 原文地址:https://www.cnblogs.com/sky20080101/p/6844537.html
Copyright © 2011-2022 走看看