#include<iostream>
using namespace std;
int main() {
int t,x[1000000];
scanf("%d",&t);
for(int i=0;i<t;i++)
scanf("%d",&x[i]);
for(int i=0;i<t;i++)
{
int c=0;
for(int j=0;j<t-1;j++)
{
int temp;
if(x[j]>x[j+1])
{
temp=x[j];
x[j]=x[j+1];
x[j+1]=temp;
c=1;
}
}
if(c==0)
break;
}
for(int i=0;i<t;i++)
printf("%d\n",x[i]);
return 0;
}
What is the question?
1 Like
Turbo sort - sort in non decreasing order
Can you send the question link?
If you simply need to sort then use inbuilt sort function. It has comp of O(nlgn)