1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ConsoleApplication1 8 { 9 class Program 10 { 11 12 static void Main(string[] args) 13 { 14 int[] number = { 1,2,3,4,3,2,4,67,5,3,2,12,-1,-4252,34}; 15 for (int i = 0; i < number.Length; i++) 16 { 17 for (int j = 0; j < number.Length-1-i; j++) 18 { 19 if(number[j+1]>number[j]) //从大到小排列 20 { 21 int num = number[j + 1]; 22 number[j + 1] = number[j]; 23 number[j] = num; 24 } 25 } 26 } 27 for (int i = 0; i < number.Length; i++) 28 { 29 Console.Write(number[i]+" "); 30 } 31 Console.ReadKey(); 32 } 33 }