zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    mac上配置apidoc环境
    Yii 2.0 GII 访问404错误
    yii框架下使用redis
    PHPEXCEL读出数据是PHPExcel_RichText类型
    php实现仿百度分页
    apache的.htaccess文件作用和相关配置
    Yii2.0 解决“the requested URL was not found on this server”问题
    [基础与理论]C#变量
    基础&理论]C#的基本语法
    [基础&理论]C#的含义
  • 原文地址:https://www.cnblogs.com/herd/p/14303199.html
Copyright © 2011-2022 走看看