NLKappa

Homework 11.10 (табл умнож)

Oct 11th, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.         System.out.println("Введите количество строк в таблице: ");
  10.         int x = sc.nextInt();
  11.         System.out.println("Введите количество столбцов в таблице: ");
  12.         int y = sc.nextInt();
  13.         int[][] arr = new int[x][y];
  14.         int a = 0;
  15.         int b = 0;
  16.  
  17.         while (a < arr.length) {
  18.             arr[a][b] = a * b;
  19.             b++;
  20.             if (b >= y) {
  21.                 b = 0;
  22.                 a++;
  23.             }
  24.         }
  25.         for (int k = 0; k < x; k++) {
  26.             for (int m = 0; m < y; m++) {
  27.                 System.out.print(arr[k][m] + " ");
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment