zoukankan      html  css  js  c++  java
  • JAVA排序的方法

    //冒泡排序法:

    package fuxi;

    public class Bubble {


        public static void main(String[] args) {
            int a[] = { 10,23,11,56,45,26,59,28,84,79 };
            int i,temp;
            System.out.println("输出原始数组数据:");
            for (i=0; i<a.length; i++) {
                 System.out.print(a[i]+" ");
             }
            for (i=0; i<9; i++) {
                if (a[i] > a[i+1]) {
                    temp = a[i];
                    a[i] = a[i+1];
                    a[i+1] = temp;
                }
            }
            System.out.println(" "+"排序号的数组数据为:");
            for (i=0; i<a.length; i++) {
                 System.out.print(a[i]+" ");
             }
        }

    }
    //选择排序方法

    package fuxi;

    public class Bubble {


        public static void main(String[] args) {
            int a[] = { 10,23,11,56,45,26,59,28,84,79 };
            int i,temp;
            System.out.println("输出原始数组数据:");
            for (i=0; i<a.length; i++) {
                 System.out.print(a[i]+" ");
             }
            for (i=0; i<9; i++) {
                if (a[i] > a[i+1]) {
                    temp = a[i];
                    a[i] = a[i+1];
                    a[i+1] = temp;
                }
            }
            System.out.println(" "+"排序号的数组数据为:");
            for (i=0; i<a.length; i++) {
                 System.out.print(a[i]+" ");
             }
        }

    }


         



         

  • 相关阅读:
    Dynamics 365/CRM 实体设计技巧
    Dynamics 365/CRM 保存之后触发onchange
    编写C#程序,计算去除最大值和最小值之后的平均值
    Dynamics 365 WebResourceUtility 工具更新
    No sandboxworker process or sandbox hosts are currently avaliable
    C#
    Dynamics CRM 365 and Azure Service Bus – Queue
    双for循环
    java switch 的练习
    java__if_else 的练习
  • 原文地址:https://www.cnblogs.com/changankaifazhe/p/10019962.html
Copyright © 2011-2022 走看看