• test


    package com.vfsd.core;
    
    public class Test1 {
        public static int[] a1= {3,8,2,5,1,9};
        public static void main(String[] args) {
            
            
            print1();
            
            for(int k=0;k<a1.length-1;k++)
            {
                for(int k2=k+1;k2<a1.length;k2++)
                {
                    int index1=a1[k];
                    int index2=a1[k2];
                    if(index1>index2)
                    {
                        a1[k]=index2;
                        a1[k2]=index1;
                        
                        
                        //continue;
                        //break;
                    }
                    
                    print1();
                }
                //print1();
            }
            
            print1();
        }
        
        public static void print1(){
            System.out.println("==================================== ");
            System.out.print(" [");
            for(int k=0;k<a1.length;k++)
            {
                System.out.print(a1[k]+" ");
            }
            System.out.print("]
    ");
            System.out.println("==================================== ");
        }
    
    }
    ==================================== 
     [3 8 2 5 1 9 ]
    ==================================== 
    ==================================== 
     [3 8 2 5 1 9 ]
    ==================================== 
    ==================================== 
     [2 8 3 5 1 9 ]
    ==================================== 
    ==================================== 
     [2 8 3 5 1 9 ]
    ==================================== 
    ==================================== 
     [1 8 3 5 2 9 ]
    ==================================== 
    ==================================== 
     [1 8 3 5 2 9 ]
    ==================================== 
    ==================================== 
     [1 3 8 5 2 9 ]
    ==================================== 
    ==================================== 
     [1 3 8 5 2 9 ]
    ==================================== 
    ==================================== 
     [1 2 8 5 3 9 ]
    ==================================== 
    ==================================== 
     [1 2 8 5 3 9 ]
    ==================================== 
    ==================================== 
     [1 2 5 8 3 9 ]
    ==================================== 
    ==================================== 
     [1 2 3 8 5 9 ]
    ==================================== 
    ==================================== 
     [1 2 3 8 5 9 ]
    ==================================== 
    ==================================== 
     [1 2 3 5 8 9 ]
    ==================================== 
    ==================================== 
     [1 2 3 5 8 9 ]
    ==================================== 
    ==================================== 
     [1 2 3 5 8 9 ]
    ==================================== 
    ==================================== 
     [1 2 3 5 8 9 ]
    ==================================== 
    QQ 3087438119
  • 相关阅读:
    array and ram
    char as int
    pointer of 2d array and address
    Install SAP HANA EXPRESS on Google Cloud Platform
    Ubuntu remount hard drive
    Compile OpenSSL with Visual Studio 2019
    Install Jupyter notebook and tensorflow on Ubuntu 18.04
    Build OpenCV text(OCR) module on windows with Visual Studio 2019
    Reinstall VirtualBox 6.0 on Ubuntu 18.04
    Pitfall in std::vector<cv::Mat>
  • 原文地址:https://www.cnblogs.com/herd/p/14303199.html
Copyright © 2020-2023  润新知