https://www.acwing.com/problem/content/description/5337/
#include<stdio.h>
void BubbleSort(int a[],int n){
int i,j,flag;
for(i=0;i<n-1;i++){
flag = 0;
for(j=n-1;j>i;j--){
if(a[j-1]>a[j]){
int t=a[j-1];
a[j-1]=a[j];
a[j]=t;
flag=1;
}
}
if(flag==0) return;
}
}
int main(){
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++) scanf("%d",&a[i]);
BubbleSort(a,n);
for(int i=0;i<n;i++) printf("%d ",a[i]);
}