Advertisement
Kmondzy

Triforce

Nov 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         int n = sc.nextInt();
  9.         int spaces = 1;
  10.         for (int i = 1; i < n; i++) {
  11.             spaces += 2;
  12.         }
  13.         int currentZvezdo4ki = 1;
  14.         for (int i = 0; i < n; i++) {
  15.             for (int j = 0; j < (3 * n) - i; j++) {
  16.                 System.out.print(" ");
  17.             }
  18.             for (int j = 0; j < currentZvezdo4ki; j++) {
  19.                 System.out.print("*");
  20.             }
  21.             currentZvezdo4ki += 2;
  22.             System.out.println();
  23.         }
  24.         currentZvezdo4ki = 1;
  25.         int currentSpaces = spaces;
  26.         for (int i = 0; i < n; i++) {
  27.             for (int j = 0; j <= spaces; j++) {
  28.                 System.out.print(" ");
  29.             }
  30.             for (int j = 0; j < currentZvezdo4ki; j++) {
  31.                 System.out.print('*');
  32.             }
  33.             for (int j = 0; j < currentSpaces; j++) {
  34.                 System.out.print(" ");
  35.             }
  36.             for (int j = 0; j < currentZvezdo4ki; j++) {
  37.                 System.out.print("*");
  38.             }
  39.             currentSpaces -= 2;
  40.             currentZvezdo4ki += 2;
  41.             spaces--;
  42.             System.out.println();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement