主题:冒泡排序类程序求助
程序创建了一个用于冒泡排序的类,需要使用该类时,将待排序的数组作为参数传给bubblesort类,即可获得排序后的输出,该程序如何才能运行(问号部份怎么填)?请各位大大帮忙
class bubblesort{
????????{
sort(a);
}
public void sort(int a[]){
int length = ?????????;
boolean isNoSwap = false;
while( ! isNoSwap ){
?????????;
for ( int i=0;i<length-1;i++ )
if ( a[i]>a[i+1] ){
int temp=a[i];
a[i]=a[i+1];
????????;
isNoSwap=false;
}
}
for ( int i=0;i<length;i++ )
System.out.println(a[i]+"");
}
}
public class test{
public static void main(String args[]){
int a[] = { 1, -1, 2, 5, -2 };
bubblesort temp = ?????????;
}
}
class bubblesort{
????????{
sort(a);
}
public void sort(int a[]){
int length = ?????????;
boolean isNoSwap = false;
while( ! isNoSwap ){
?????????;
for ( int i=0;i<length-1;i++ )
if ( a[i]>a[i+1] ){
int temp=a[i];
a[i]=a[i+1];
????????;
isNoSwap=false;
}
}
for ( int i=0;i<length;i++ )
System.out.println(a[i]+"");
}
}
public class test{
public static void main(String args[]){
int a[] = { 1, -1, 2, 5, -2 };
bubblesort temp = ?????????;
}
}