JeffGrigg

GaganAjayBansal

Apr 23rd, 2017
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.52 KB | None | 0 0
  1. public class GaganAjayBansal {
  2.     public static void main(String[] args) {
  3.         for (int i = 1; i <= 7; i++) {
  4.             int val= 0; // value to be printed
  5.             int count = 1; // used for logic
  6.             for (int j = 1; j <= i+i-1; j++) {
  7.                 if (count <= i) {
  8.                     val++;
  9.                 } else {
  10.                     val--;
  11.                 }
  12.                 System.out.print(val + " ");
  13.                 count++;
  14.             }
  15.             System.out.println();
  16.         }
  17.     }
  18. }
Add Comment
Please, Sign In to add comment