public class First { public static void main(String[] args){ int []a={2,1,3,4,5,6,7,8,9,11}; int sum=0; for (int i=0;i<a.length-1;i++){ for (int j=i+1;j<a.length;j++){ if(a[i]>a[j]){ int temp=a[i]; a[i]=a[j]; a[j]=temp; } } } for(int i=0;i<a.length;i++){ System.out.println(a[i]);} System.out.println("min"+a[0]); System.out.println("max"+a[9]); sum=a[0]+a[9]; System.out.println(sum/2); } }
时间: 2024-10-11 21:57:57