冒泡排序 .

 
  1. static void BubbleSort(int[] nums)  
  2.         {  
  3.             int temp;  
  4.             for (int i = 0; i <= nums.Length -1; i++)  
  5.             {  
  6.                 for (int j = 0; j <= nums.Length - 1 - i; j++)  
  7.                 {  
  8.                     if (nums[j] > nums[j + 1])  
  9.                     {  
  10.                         temp = nums[j];  
  11.                         nums[j] = nums[j + 1];  
  12.                         nums[j + 1] = temp;  
  13.                     }  
  14.                 }  
  15.             }  
  16.         }  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章