Support Me...........

Please support me by giving donation

contact: aswinavofficial@gmail.com


Total Pageviews

Monday, September 1, 2014

C++ program to perform Bubble Sort

//Bubble sort #include using namespace std; int compare(int, int); void sort(int[], const int); void swap(int *, int *); int compare(int x, int y) { return(x > y); } void swap(int *x, int *y) { int temp; temp = *x; *x = *y; *y = temp; } void display(int array[], int n) { for (int i=0; i> quantity; tab = new int [quantity]; cout << "Input numbers: \n\n"; for (int i = 0; i < quantity; i++) { int x = i; cout << "#" << ++x << ": "; cin >> tab[i]; } cout << "\nBefore sorting: "; display(tab, quantity); cout << endl; sort(tab, quantity); cout << "\nAfter sorting: "; display(tab, quantity); cout << endl; return 0; } // aiuto

No comments: