Muhaiminur
2/12/2018 - 8:00 PM

Hollow Triangle - Left Justified Number

Hollow Triangle - Left Justified Draw right angled triangle of given height Sample input: 5 Sample output 1 12 1 3 1 4 12345

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BASICJAVA;

import java.util.Scanner;

/**
 *
 * @author ABIR
 */
public class Hollow_Triangle_Left_Justified_Number {
    public static void main(String[]args){
        Scanner abir=new Scanner(System.in);
        System.out.println("Enter sample input");
        int x=abir.nextInt();
        System.out.println("sample output");
        System.out.println(1);
        int c=0;
        while(c<x-2){
          System.out.print(c+1);
          int y=c;
          int d=0;
          while(d<y){
           System.out.print(" ");
           d++;
          }
          c++;
          System.out.print(d+1);
          System.out.println();
        }
        int e=0;
        while(e<x){
          System.out.print(e+1);
          e++;
        }
        System.out.println();
        System.out.println("=======================================================");
      }
}