Advertisement
JeffGrigg

OptimizeThis

Dec 12th, 2018
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.56 KB | None | 0 0
  1. public class OptimizeThis {
  2.     public static void main(String[] args) {
  3.         int size = 9;
  4.         for (int i = 1; i <= size; i++) {
  5.             for (int j = 1; j <= size * 2 - 1; j++) {
  6.                 if (i > 1 && size > i && ((i * 2 - 1 == j) || size * 2 - i * 2 + 1 == j)) {
  7.                     System.out.print(" ");
  8.                 } else if (j % 2 == 0) {
  9.                     System.out.print(" ");
  10.                 } else {
  11.                     System.out.print("*");
  12.                 }
  13.             }
  14.             System.out.println();
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement