Advertisement
Boyan5

oop7

Jun 24th, 2021
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class zad7 {
  3.     public static void main(String[] args) {
  4.         System.out.println("Enter the height: ");
  5.         Scanner scan = new Scanner(System.in);
  6.         int height = scan.nextInt();
  7.         for (int i = 0; i < height ; i++) {
  8.             for (int j = 1; j <height-i ; j++) {
  9.                 System.out.print(" ");
  10.             }
  11.             int num = 1;
  12.             for (int j = 0; j <=i ; j++) {
  13.                 System.out.print(num + " ");
  14.                 num = num * (i-j)/(j+1);
  15.             }
  16.             System.out.println();
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement