#include<iostream>
using namespace std;
void createArray(int* arr,int n)
{
for (int i = 0;i < n;i++)
{
cin >> arr[i];
}
}
void bubbleSort(int* arr, int n)
{
for (int i = 0;i < n - 1;i++)
{
bool swap = false;
for (int j = 0;j < n - 1 - i;j++)
{
if (arr[j] < arr[j + 1])
{
int temp=arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
swap = true;
}
}
if (swap == false)break;
}
}
void printArray(int arr[], int n)
{
cout << "Print the elements of the array: ";
for (int i = 0;i < n;i++)
{
cout << arr[i]<<" ";
}
}
int main()
{
int* arr = new int[50];
int n;
cout << "Please enter the number of the array: ";
cin >> n;
cout << "Please enter the element of the array: ";
createArray(arr, n);
bubbleSort(arr, n);
printArray(arr, n);
delete[] arr;
return 0;
}