package com.example.practice.common;

import org.junit.jupiter.api.Test;

public class Java_Two_Array {


    @Test
    public void test() {
        int m = 3;//行
        int n = 6;//列
        int[][] arr = new int[m][n];


        System.out.println("行数:" + arr.length);
        System.out.println("列数:" + arr[0].length);

        //第一列都赋值为1
        System.out.println("3x6 的二维数组");
        System.out.println("第一列都赋值为1");
        System.out.println(" ");
        for (int i = 0; i < m; ++i) {
            arr[i][0] = 1;
        }

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
    }


    @Test
    public void test2() {
        int m = 3;//行
        int n = 6;//列
        int[][] arr = new int[m][n];

        //第一行都赋值为1
        System.out.println("3x6 的二维数组");
        System.out.println("第一行都赋值为1");
        System.out.println(" ");
        for (int i = 0; i < n; ++i) {
            arr[0][i] = 1;
        }

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
    }

}
