Wednesday, June 11, 2014

/ * Bubble sort * / # include


/ * Bubble sort * / # include <iostream.h> void bubble (int arr [], int n); void show (int [], int); void main (void) {int bubble_arr [10] = {0 , 0,0,0,0,0,0,0,0,0}; int i; for (i = 0; i <10; i + +) {cout << "Please input" << i +1 << ":"; cin >> bubble_arr [i];} / / assume custom foam that the user input is ideal cout << "Sort ago:"; show (bubble_arr, 10); bubble (bubble_arr, 10); cin.get () ;} void bubble (int arr [], int n) / / bubble sort {int i, j, temp; for (i = 0; i <n-1; i + +) {for (j = 0; j <ni- 1; j + +) {if (arr [j]> arr [j +1]) {temp = arr [j +1]; arr [j +1] = arr [j]; arr [j] = temp;}} cout << "Sort" << i +1 << "times:"; show (arr, 10);}} void show (int arr [], int n) / / print the array values {int i; for (i = 0; i <n; i + +) cout << arr [i] << ""; cout << "\ n";} would like to thank the year in the digital master custom foam (NBP) to share friends, I will be data collection originally published here and try to name the note.
You are not logged in, a message will be as a visitor. You can also post a message above the service account selection


No comments:

Post a Comment