Advertisement
sergAccount

Untitled

Jul 10th, 2021
1,047
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 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.dz3;
  7.  
  8. /**
  9.  *
  10.  * @author student
  11.  */
  12. public class Main {    
  13.     /*
  14.     Задача2
  15.     Создать метод, который выводит символ c - параметр данного метода
  16.     в виде элементов таблицы из n-строк и m-столбцов - параметров данного метода
  17.     public static void printTable(char c, int n, int m){
  18.  
  19.     }
  20.     Проверить данный метод вызвать в методе main
  21.     Пример
  22.     Символ: A Кол-во строк: 2   Кол-во столбцов: 3  
  23.     Вывод:
  24.     A A A
  25.     A A A
  26.     */
  27.     public static void printTable(char c, int n, int m){
  28.         // for или while
  29.         //System.out.println(c);
  30.         //System.out.print(c);
  31.         for (int i = 0; i < n; i++) {
  32.             for (int j = 0; j < m; j++) {
  33. //                System.out.print(c);                
  34. //                System.out.print(' ');                
  35.                 System.out.print(c + " ");                                
  36.             }            
  37.             //System.out.println("");
  38.             System.out.println();
  39.         }
  40.     }
  41.     //
  42.     public static void main(String[] args) {
  43.         // вызов метода printTable
  44.         printTable('A', 2, 4); // 2-кол-во строк, 3-кол-во столбцов
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement