码迷,mamicode.com
首页 > 编程语言 > 详细

2014/12/12实现统计数组每行最小值,每列最大值

时间:2014-12-12 10:02:32      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:ar   sp   for   2014   bs   as   new   nbsp   br   

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实现统计数组每行最小值,每列最大值

标签:ar   sp   for   2014   bs   as   new   nbsp   br   

原文地址:http://www.cnblogs.com/zhizhuniuniu/p/4159060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!