input標籤中:class=”{active=isActive}”的Boolean值沒有效果的解決方法。
阿新 • • 發佈:2020-12-14
1 //快速排序 2 #include<iostream> 3 #include <algorithm> 4 using namespace std; 5 int kuaipai1(int r[], int first, int end) 6 { 7 int i = first; 8 int j = end; 9 while (i<j) 10 { 11 while (i<j&&r[i]<=r[j]) 12 { 13 j--; 14 }15 if (i<j) 16 { 17 swap(r[i], r[j]); 18 ++i; 19 } 20 while (i<j&&r[i]<=r[j]) 21 { 22 i++; 23 } 24 if (i<j) 25 { 26 swap(r[j], r[i]); 27 j--; 28 } 29} 30 return i; 31 } 32 void kuaipai2(int r[], int first, int end) 33 { 34 if (first<end) 35 { 36 int p = kuaipai1(r, first, end); 37 kuaipai2(r, first, p - 1); 38 kuaipai2(r, p + 1, end); 39 } 40 } 41 int main() 42 { 43 int r[5] = { 7,2,4,8,1 }; 44 kuaipai2(r,0,4); 45 for (auto x : r) 46 { 47 cout << x << " "; 48 } 49 return 0; 50 }