Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- int rows;
- int cols;
- System.out.printf("How many rows does your array have? ");
- rows = in.nextInt();
- System.out.printf("How many coloumns does your array have? ");
- cols = in.nextInt();
- ArrIni array = new ArrIni(rows, cols);
- array.printTable();
- in.close();
- }
- }
- // Next class
- public class ArrIni
- {
- int[][] array;
- public ArrIni(int rows, int cols)
- {
- array = new int[rows][cols];
- for(int i = 0; i < array.length; i++)
- for(int j = 0; j < array[i].length; j++)
- array[i][j] = j + (i * 10);
- }
- public void printTable()
- {
- for(int i = 0; i < array.length; i++)
- {
- for(int j = 0; j < array[i].length; j++)
- System.out.printf("%d\t", array[i][j]);
- System.out.printf("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement