Advertisement
psi_mmobile

Untitled

Mar 27th, 2022
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         int maxStars = 55;
  4.         int gaps = maxStars/2 - 1;
  5.         for(int i = 1; i < maxStars; i=i+2) {
  6.                 for (int p = 0; p <=gaps;p++) {
  7.                     System.out.print(" ");
  8.                 }
  9.                 for (int j = 0; j < i; j++) {
  10.                 System.out.print("*");
  11.                 }
  12.                 for (int p = 0; p <=gaps;p++) {
  13.                     System.out.print(" ");
  14.                 }
  15.                 gaps--;
  16.                 System.out.println("");
  17.         }
  18.         gaps = 0;
  19.         for(int i = maxStars; i <= maxStars; i=i-2) {
  20.             for (int p = 0; p <gaps;p++) {
  21.                     System.out.print(" ");
  22.             }
  23.             for (int j = 0; j < i; j++) {
  24.                 System.out.print("*");
  25.             }
  26.             for (int p = 0; p <gaps;p++) {
  27.                     System.out.print(" ");
  28.             }
  29.             gaps++;
  30.             System.out.println("");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement