首页 > 代码库 > 2014/12/12实现统计数组每行最小值,每列最大值
2014/12/12实现统计数组每行最小值,每列最大值
package myjar2;
public class myjar2 {
public static void main(String[] args) {
int a[][] = new int[5][6];
int min[] = { 100, 100, 100, 100, 100 }, max[] = { 0, 0, 0, 0, 0, 0 };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 5; j++) {
a[i][j] = (int) (Math.random() * 100);
if (min[i] > a[i][j]) {
min[i] = a[i][j];
}
if (max[j] < a[i][j]) {
max[j] = a[i][j];
}
a[i][5] = min[i];
a[4][j] = max[j];
}
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 6; j++) {
if(i!=4||j!=5){
System.out.print(a[i][j] + "\t");
}
}
System.out.println();
}
}
}
2014/12/12实现统计数组每行最小值,每列最大值