borkins

06. Rhombus of Stars

Apr 5th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. /**
  2.  * Project: Drawing_With_Loops - created by borkins on 2017-04-01.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _06_RhombusOfStars
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.         StringBuilder sb = new StringBuilder();
  13.        
  14.         int n = Integer.parseInt(console.nextLine());
  15.        
  16.         for (int row = 0; row < n; row++)
  17.         {
  18.             sb.append("*");
  19.             for (int col = row; col < n - 1; col++) {
  20.                 System.out.print(" ");
  21.             }
  22.             System.out.println(sb);
  23.             sb.append(" ");
  24.         }
  25.        
  26.         for (int row = 0; row < n - 1; row++)
  27.         {
  28.             sb.setLength(sb.length() - 2);
  29.             for (int col = 0; col < row + 1; col++) {
  30.                 System.out.print(" ");
  31.             }
  32.             System.out.println(sb);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment