zoukankan      html  css  js  c++  java
  • 数组求最大最小值和排序java实现

    public class ArrayDemo05 {
    public static void main(String[] args) {
        int list01[]={67,89,87,69,90,100,75,90};
        int max;
        int min;
        max=min=list01[0];
        for(int i=0;i<list01.length;i++){
            if (list01[i]>max)
                max=list01[i];
            if(list01[i]<min)
                min=list01[i];
        }
        System.out.println("The max value is:"+max);
       
    //    for(int i=0;i<list01.length;i++){
    //        if(list01[i]<min)
    //            min=list01[i];
    //    }
        System.out.println("The min value is:"+min);
       
        System.out.print("原始数组1的结果: ");
        for(int i=0;i<list01.length;i++){
            System.out.print(list01[i]+" ");
        }
        System.out.println("");
        for(int i=1;i<list01.length;i++){
            for(int j=0;j<list01.length;j++){
                if(list01[j]>list01[i]){
                    int temp=list01[i];
                    list01[i]=list01[j];
                    list01[j]=temp;
                }
            }
            System.out.print("第"+i+"次排序的结果: ");
            for(int k=0;k<list01.length;k++){
                System.out.print(list01[k]+" ");
            }
            System.out.println("");
        }
        for(int i=0;i<list01.length;i++){
        System.out.print(list01[i]+" ");
        }
    }
    }

  • 相关阅读:
    1144 The Missing Number (20分)
    1145 Hashing
    1146 Topological Order (25分)
    1147 Heaps (30分)
    1148 Werewolf
    1149 Dangerous Goods Packaging (25分)
    TypeReference
    Supervisor安装与配置()二
    谷粒商城ES调用(十九)
    Found interface org.elasticsearch.common.bytes.BytesReference, but class was expected
  • 原文地址:https://www.cnblogs.com/vonk/p/3885010.html
Copyright © 2011-2022 走看看