public class Qsort{
public static void main(String[] args){
int[] arry={5,6,4,2,1,5,3,4};
int tem=0;
boolean s;
int count=0;
for(int i=0;i<arry.length-1;i++){
s=false;
for(int j=0;j<arry.length-i-1;j++){
if(arry[j]>arry[j+1]){
tem=arry[j];
arry[j]=arry[j+1];
arry[j+1]=tem;
s=true;
}
count++;
}
if(!s)
break;
}
for(int i=0;i<arry.length;i++){
System.out.print(arry[i]+" ");
}
System.out.println(count);
}
}
public static void main(String[] args){
int[] arry={5,6,4,2,1,5,3,4};
int tem=0;
boolean s;
int count=0;
for(int i=0;i<arry.length-1;i++){
s=false;
for(int j=0;j<arry.length-i-1;j++){
if(arry[j]>arry[j+1]){
tem=arry[j];
arry[j]=arry[j+1];
arry[j+1]=tem;
s=true;
}
count++;
}
if(!s)
break;
}
for(int i=0;i<arry.length;i++){
System.out.print(arry[i]+" ");
}
System.out.println(count);
}
}