22:37

Double Array

Posted by Mitesh Patel |


import java.util.Scanner;

class TwoDArray {

    public static void main(String args[]) {

        int Row, Col;

        int a[][] = new int[3][3];

        for (Row = 0; Row < 3; Row++) {
            for (Col = 0; Col < 3; Col++) {

                a[Row][Col] = new Scanner(System.in).nextInt();

            }
        }



        //print data

        for (Row = 0; Row < 3; Row++) {
            for (Col = 0; Col < 3; Col++) {

                System.out.print("\t" + a[Col][Row]);

            }
            System.out.print("\n");
        }


    }
}

0 comments:

Post a Comment

Subscribe