mstoyanova

Untitled

Apr 22nd, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package com.Exam;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Forest_Road {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int n = scanner.nextInt();
  9.         int height = 2 * n - 1;
  10.         int position = 0;
  11.  
  12.  
  13.         String[][] arr = new String[n][height];
  14.  
  15.         for (int i = 0; i < n; i++) {
  16.             for (int j = 0; j < height; j++) {
  17.                 if (i == j) {
  18.                     arr[i][j] = "*";
  19.                     System.out.print(arr[i][j] + " ");
  20.  
  21.                 }
  22.                 else {
  23.                     arr[i][j] = ".";
  24.                     System.out.print(arr[i][j] + " ");
  25.                 }
  26.                
  27.             }
  28.             System.out.println();
  29.         }
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment