本文仅用作学习记录,大神勿喷O(∩_∩)O~

代码一、百度百科C++语言版本代码,参考数据结构p274(清华大学出版社,严蔚敏)

 1 void Qsort1(int a[], int low, int high)//百度百科C++语言版本代码 
 2 {/*参考数据结构p274(清华大学出版社,严蔚敏)*/
 3     if(low >= high) return;
 4     int first = low;
 5     int last = high;
 6     int key = a[first];/*用字表的第一个记录作为枢轴*/
 7  
 8     while(first < last)
 9     {
10         while(first < last && a[last] >= key)
11         {
12             --last;
13         }
14         a[first] = a[last];/*将比第一个小的移到低端*/
15         while(first < last && a[first] <= key)
16         {
17             ++first;
18         }
19         a[last] = a[first];    
20         /*将比第一个大的移到高端*/
21     }
22     a[first] = key;/*枢轴记录到位*/
23     Qsort1(a, low, first-1);
24     Qsort1(a, first+1, high);
25 }
View Code

相关文章:

  • 2022-01-17
  • 2021-06-19
  • 2022-12-23
  • 2021-05-31
  • 2021-12-22
  • 2021-11-20
  • 2021-12-19
  • 2021-12-19
猜你喜欢
  • 2022-01-20
  • 2021-12-19
  • 2021-11-30
  • 2021-08-26
  • 2021-12-02
  • 2021-05-20
  • 2021-06-13
相关资源
相似解决方案