Advertisement
GeorgeDI

Java_Triangle_Numbers

Oct 15th, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1.  
  2. public class NumbersTriangle_19 {
  3.  
  4.     public static void main(String[] args) {
  5.         int rows = 5;
  6.  
  7.         for (int i = 1; i <= rows; ++i) {
  8.             for (int j = 1; j <= i; ++j) {
  9.                 System.out.print(j + " ");
  10.             }
  11.             System.out.println();
  12.  
  13.             // follows The reversed part Triangle
  14.             // How to merge the two triangles?
  15.             //Some interruption(if/then)after the first triangle prints the max row number?/
  16.  
  17.             for (int i = rows; i >= 1; --i) {
  18.                 for (int j = 1; j <= i; ++j) {
  19.                     System.out.print(j + " ");
  20.                 }
  21.                 System.out.println();
  22.             }
  23.         }
  24.     }
  25. }
  26. // Resources used : https://www.programiz.com/java-programming/examples/pyramid-pattern
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement