求说明一下冒泡排序的代码
求大虾说明一下冒泡排序的代码。
求大虾说明一下冒泡排序的代码。3Q。
------解决方案--------------------
publicclassBubbleSort {
publicvoidsort(int[]a) {
inttemp=0;
for(inti=a.length-1;i>0;--i)
{
for(intj=0;j<i;++j)
{
if(a[j+1]<a[j])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
}
求大虾说明一下冒泡排序的代码。3Q。
------解决方案--------------------
publicclassBubbleSort {
publicvoidsort(int[]a) {
inttemp=0;
for(inti=a.length-1;i>0;--i)
{
for(intj=0;j<i;++j)
{
if(a[j+1]<a[j])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
}