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]);
                }
            }
    
        }
    }

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

  • 相关阅读:
    Vue——动画
    Vue——v-if 和 v-show 的使用和特点
    Vue——v-for中 key 属性的使用
    Vue——基础指令
    Vue——v-for指令的四种循环方式
    Vue——如何在Vue中使用样式
    mac安装redis
    常见的web攻击方式
    mobx 入门
    Mac显示器不亮
  • 原文地址:https://www.cnblogs.com/shanhua-fu/p/7903156.html
Copyright © 2011-2022 走看看