Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void buble_sort(int arr[], int n) {
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n - i - 1; j++) {
- if(arr[j] < arr[j + 1]) {
- swap(arr[j], arr[j + 1]);
- }
- }
- }
- }
- int main()
- {
- int array_to_sort[15] = {4, 30, 79, 11, 40, 52, 93, 13, 97, 80, 44, 50, 31, 44, 19};
- buble_sort(array_to_sort, 15);
- for(int x : array_to_sort) {
- cout << x << " ";
- }
- return 0;
- }
- /* 97 93 80 79 52 50 44 44 40 31 30 19 13 11 4 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement