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

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

  • 相关阅读:
    利用Telnet来模拟Http请求 有GET和POST两种
    WebConfig特殊字符的转义!
    userprofile同步用户失败的原因和解决方案
    linux mysql表名大小写
    web.py 中文模版报错
    docker 开启远程
    web.py 笔记
    python 安装influxdb-python
    安装pip
    influxdb 命令
  • 原文地址:https://www.cnblogs.com/shanhua-fu/p/7903156.html
Copyright © 2011-2022 走看看