SortAlgorithm/Program.cs

(开头部分) 10KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SortAlgorithm
{
    class Program
    {
        private  static int[] data = new int[] { 12, 43, 2, 34, 87, 54, 32, 16, 67, 99,49 };
        static void Main(string[] args)
        {
            HeapSort(data.Length);
            //QuickSort(0, data.Length - 1);
            //MergeSort(0, data.Length);
            //RadixSort();
            //#region
            //DoubleBubbleSort();
            //Console.WriteLine("排序最终结果:");
            //#endregion
            //SelectionSort();
            //InsertSortStraight();
            //InsertSortShell();
            PrintData();

            Console.Read();
        }

        private static void PrintData()
        {
            for (int i = 0; i < data.Length; i++)
            {
                Console.Write(data[i]);
                if(i!=data.Length-1)
                {
                    Console.Write(",");
                }
            }
        }
        #region 交换排序
        #region 冒泡排序
        //冒泡排序  气泡一样由下往上 从最后一个依次跟之前的比较
        public static void BubbleSort()
        {
            for(int i=1;i<data.Length-1;i++)
            {
                for(int j=data.Length-1;j>=i;j--)
                {
                    if(data[j]<data[j-1])
                    {
                        int temp = data[j];
                        data[j] = data[j-1];
                        data[j - 1] = temp;
                    }
                }
                Console.WriteLine("第" + i + "次");
                PrintData();
            }
        
后面还有 303 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。