日期:2014-05-20 浏览次数:20903 次
int [][]a = {{23,34,54,34},{54,3,645,75},{134,65,87,98}}; int c[] ; c = new int[a.length]; int temp; for(int i=0;i<a.length;i++){ temp = a[i][0]; for(int j=1;j<a[i].length;j++){ if(a[i][j]>temp){ temp = a[i][j]; } } c[i]=temp; } System.out.println(Arrays.toString(c)); int min = c[0]; for(int m=1;m<c.length;m++){ if(c[m]<min){ min = c[m]; } } System.out.println(min);
------解决方案--------------------
或者
int [][]a = {{23,34,54,34},{54,3,645,75},{134,65,87,98}}; int c[] ; c = new int[a.length]; int temp=0,Temp=0; for(int i=0;i<a.length;i++){ temp = a[i][0]; for(int j=1;j<a[i].length;j++){ if(a[i][j]>temp){ temp = a[i][j]; } } c[i]=temp; if(i==0){ Temp = temp; } else if(Temp>temp){ Temp = temp; } } System.out.println(Temp);
------解决方案--------------------