public void sort(int[ ] arr)
import java.util.Arrays;
import java.util.Scanner;
public class Test {
int temp=0;
public void sort(int[] arr) {
for(int i = 0;i<arr.length-1;i++){
for(int j = 0;j<arr.length-i-1;j++){
if(arr[j]>arr[j+1]){
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1]=temp;
}
}
}
}
public static void main(String[] args) {
Test t=new Test();
Scanner scanner=new Scanner(System.in);
System.out.println("请输入数组元素个数:");
int n=scanner.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++) {
System.out.println("请输入第"+(i+1)+"个元素");
arr[i]=scanner.nextInt();
}
t.sort(arr);
System.out.println(Arrays.toString(arr));
}
}