Advertisement
sergAccount

Untitled

Aug 9th, 2020
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.app8;
  7.  
  8. /**
  9.  *
  10.  * @author Admin
  11.  */
  12. public class Test5 {
  13.    
  14.     /*
  15.     Вывести на экран числа в виде таблицы
  16.     (использовать for, while)
  17.     Объявить переменные rows, cols - типа int, присвоить занчения переменным  
  18.     */
  19.     //
  20.     public static void main(String[] args) {
  21.         //
  22.         int rows = 3;
  23.         int cols = 5;
  24.         /*
  25.         1 2 3 4 5
  26.         1 2 3 4 5
  27.         1 2 3 4 5
  28.         */
  29.         for (int i = 1; i <= rows; i++) {
  30.             //System.out.println(i);  
  31.             for (int j = 1; j <= cols; j++) {                            
  32.                  System.out.print(j);                
  33.                  System.out.print(" ");                
  34.             }
  35.             // добавление перевода строки после вывода значений таблицы
  36.             System.out.println(); // System.out.println("");
  37.         }
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement