#include <iostream>
using namespace std;
int main(){
int t;
cout << "Enter the array size: ";
cin >> t;
char array[t];
cout << "\nEnter the values:\n";
for(int i=0;i<t;i++){
cin >> array[i];
}
cout << "\n\nThe array before sorting: ";
for(int i=0;i<t;i++){
cout << array[i] << " ";
}
cout << "\n\nThe array after sorting in ascending order: ";
int temp;
for(int i=0;i<t;i++){
for(int j=0;j<t-i;j++){
if(array[j]>array[j+1]){
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
//array[t+1]='\0';
for(int i=0;i<t;i++){
cout << array[i] << " ";
}
cout << "\n\nThe array after sorting in descending order: ";
for(int i=t-1;i>=0;i--){
cout << array[i] << " ";
}
cout << "\n\n\n";
return 0;
}