zoukankan      html  css  js  c++  java
  • java--数组

    public class ArryDemo {
    
        public static void main(String[] args) {
            //元素类型[] 数组名 = new 元素类型[元素个数或者元素长度]
            
            //int[] x = new int[3];
            //int[] arry = new int[]{1,3,4};
            int[] arry = {34,45,44,88};
            //for (int i = 0; i < arry.length; i++) {
            //System.out.println(arry[i]);
            //}
            printArry(arry);
            
        }
        
        public static void printArry(int[] Arry){
            
            for (int i = 0; i < Arry.length; i++) {
                if(i<Arry.length-1){
                    System.out.print(Arry[i]+",");
                }else{
                    System.out.println(Arry[i]);
                }
                        
            }
        }
    }

    ##########数组的排序#############

    #######选择排序

    public class ArryDemo {
    
        public static void main(String[] args) {
            //元素类型[] 数组名 = new 元素类型[元素个数或者元素长度]
            
            //int[] x = new int[3];
            //int[] arry = new int[]{1,3,4};
            int[] arry = {34,45,44,88};
            //for (int i = 0; i < arry.length; i++) {
            //System.out.println(arry[i]);
            //}
            printArry(arry);
            Arry(arry);
            printArry(arry);
            
        }
        
        public static void Arry(int[] Arry){
            for (int i = 0; i < Arry.length-1; i++) {
                for (int j = i+1; j < Arry.length; j++) {
                    if(Arry[i]>Arry[j]){
                        int tmp = Arry[i];
                        Arry[i]=Arry[j];
                        Arry[j]=tmp;
                        
                        
                    }
                    
                }
                
            }
    
        }
        public static void printArry(int[] array){                       ####打印数组
            for (int i = 0; i < array.length; i++) {
                if(i!=array.length-1){
                    System.out.print(array[i]+",");
                }else{
                    System.out.println(array[i]);
                }
            }
    
        }
    }

    ##########冒泡排序##############

  • 相关阅读:
    背水一战 Windows 10 (97)
    背水一战 Windows 10 (96)
    背水一战 Windows 10 (95)
    背水一战 Windows 10 (94)
    背水一战 Windows 10 (93)
    Vue项目用于Ios和Android端开发
    Android assets文件夹之位置放置和作用
    轻松搭建Xposed Hook
    cordov vue项目中调用手机原生api
    Android 直接修改dex破解
  • 原文地址:https://www.cnblogs.com/shanhua-fu/p/7903156.html
Copyright © 2011-2022 走看看