zoukankan      html  css  js  c++  java
  • 关于排序

    基础排序,大神请路过

    冒泡排序:

    class Program

             {

                //冒泡排序,从小到大

                static void Main(string[] args)

                {

                    int[] Arr = { 3242, 6, 54324, 9, 10 };

                    for (int i = 0; i < Arr.Length; i++)

                    {

                        int k = 0;

                        for (int j = 0; j < Arr.Length; j++)

                        {

                            if (Arr[i] < Arr[j])

                            {

                                k = Arr[i];

                                Arr[i] = Arr[j];

                                Arr[j] = k;

                            }

                        }

                    }

                    for (int i = 0; i < Arr.Length; i++)

                    {

                        Console.WriteLine(Arr[i] + " ");

                    }

                    Console.ReadLine();

                }

            }

    快速排序:

    Static  Viod Main(stirng[] args)

    {

       Int [] arry={10, 25, 9, 56, 2, 48};

    QuSort(arry, 0 ,5);

    For(int i=0; i<arr.length; i++)

    {

      Console.Write(arr[i]);

    }

    Console.Write();

    }

    Public  static  QuSort (int [] arr ,int low, int hing )

    {

    //10  25  9  56  2  48

    If(!low<hing)

    {

      Return;

    }

         Int i=low; int j=hing; temp=arr[low];

         While(i<j){

       While(low<hing&&temp<arr[j])

    {

       j--;

    }

    If(i<j&&tmep>=arr[j])

    {

       Arr[i]=arrr[j];

       i++;

    }

    While (i<j&&temp>arr[i])

    {

       I++;

    }

    If(i<j&&temp<=arr[i])

    {

      Arr[j]=arr[i];

      J--;

    }

    }

    Arr[i]=temp;

    QuSort(arr,low,i-1);

    QuSort(arr,i+1,hing);

    }

  • 相关阅读:
    2018年5月份
    2018年4月份
    2018年3月份
    2018年2月份
    代码书写欣赏
    关于Model层中Datetime Datetime? 默认值的问题
    关于DotNetBar中DataGridViewX 自动全屏 Anchor属性无效问题
    关于ios 8 7 下的模态窗口大小的控制 代碼+場景(mainstoryboard)( Resizing UIModalPresentationFormSheet )
    ios 关于StoryBoard 的简易使用说明
    VS2012 Build相关
  • 原文地址:https://www.cnblogs.com/dongwenhua/p/9000972.html
Copyright © 2011-2022 走看看