C# 冒泡排序

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace ConsoleApp1
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             int[] shu = { 1, 4, 7, 4, 2, 8, 5, 9 };
14 
15             for (int i = 0; i < shu.Length - 1; i++)
16             {
17                 for (int j = 0; j < shu.Length - i- 1; j++)
18                 {
19                     if (shu[j + 1] > shu[j])
20                     {
21                         int temp = shu[j + 1];
22                         shu[j + 1] = shu[j];
23                         shu[j] = temp;
24                     }
25                 }
26             }
27             for (int i = 0; i < shu.Length; i++)
28             {
29                 Console.Write(shu[i] + "");
30             }
31             Console.ReadKey();
32         }
33     }
34 }
原文地址:https://www.cnblogs.com/Peng18233754457/p/7903985.html