C code:

 1  //对数组a[MAX]进行冒泡排序
 2  void BubbleSort(int a[])
 3 {
 4      int temp = 0;    //临时变量 
 5      int i = 0;  
 6      for (i=0; i<MAX; i++)
 7      {
 8          if ( a[i] > a[i+1])
 9          {
10             temp = a[i];
11             a[i] = a[i+1];
12             a[i+1] = temp;
13         }
14     }
15 }

 

相关文章:

  • 2021-11-22
  • 2021-07-09
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2021-07-04
  • 2022-12-23
猜你喜欢
  • 2021-11-11
  • 2021-11-09
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案