#include<bits/stdc++.h>
using namespace std;
#define ll long long
void bubblesort(ll a[],ll n)
{
for(ll i=0;i<n;i++)
{
for(ll j=0;j<n;j++)
{
if(a[j]>a[j+1])
{
ll t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
for(ll i=0;i<n;i++)
cout<<a[i]<<endl;
}
int main()
{
// let’s play
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
{
cin>> a[i];
}
bubblesort(a,n);
return 0;
}
I am not able to pass all test case for bubble sort here is my code
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.