冒泡排序

方式一:

 1 public static void Sort(int[] array)
 2         {
 3             for (int i = 0; i < array.Count(); i++)
 4             {
 5                 for (int j = i+1; j < array.Count(); j++)
 6                 {
 7                     if (array[i]>array[j])
 8                     {
 9                         int temp = array[i];
10                         array[i] = array[j];
11                         array[j] = temp;
12                     }
13                 }
14             }
15 
16             foreach (var item in array)
17             {
18                 Console.WriteLine(item);
19             }
20         }

 

posted @ 2016-03-14 12:11  the boy、图样图森破  阅读(170)  评论(0编辑  收藏  举报