int arr[] = {2,5,8,98,6,81,51};int arr1[] ={2,5,8,98,6,81,51};for(int i=0;ifor(int j=i+1;j if (arr[i]>arr[j]){ int temp = arr[i]; arr[i]=arr[j]; arr[j]=temp; } }}这时的arr数组就是排好序的了arr[0]就是最小的,arr[arr.length()-1]就是最大的