public class MaoPao2 {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println("请输入:");
Integer st = s.nextInt();
Integer[] list = new Integer[st];
De d = new De();
d.mp(list);
for(int i=0; i<list.length; i++){
System.out.println(list[i]+" ");
}
}
}
class De{
public static void mp(Integer[] arr){
for(int x=0; x<arr.length-1; x++){
for(int y=0; y<arr.length -x -1; y++){
if(arr[y]<arr[y+1]){
int temp = arr[y+1];
arr[y+1] = arr[y];
arr[y] = temp;
}
}
}
}
}
为什么运行报错 |
|