Bubble sort Learning
# Include
Using namespace std; void BubbleSort (int ary [], int length) {int I, j; for (I = 0; I <length; I ++) {for (j = 1; j
Ary [j]) {swap (ary [J-1], ary [j]) ;}}// bubble sort 2 void BubbleSort2 (int a [], int n) {int j, k; bool flag; k = n; flag = true; while (flag) {flag = false; for (j = 1; j <k; j ++) if (a [j-1]> a [j]) {swap (a [j-1], a [j]); flag = true;} k --;}} int main (int argc, char * argv []) {int a [] = {,}; BubbleSort2 (a, 9 ); for (int I = 0; I <9; I ++) {cout
<Running effect:
Learning from: MoreWindows (Learning simple and complex Classical Vernacular algorithms that can be viewed)
- MoreWindows vernacular classical algorithm series explain a variety of classical algorithms in the most easy-to-understand language, including various sorting algorithms and some ingenious interview question solutions. This series of articles is in-depth and informative. It helps readers thoroughly master the articles on the basis of understanding and uses image examples to impress readers.