gusmantap
11/15/2019 - 6:22 AM

Segitiga piramid

Segitiga piramid

/*
 * 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 latihan;

/**
 *
 * @author Bagus
 */
public class Segitiga {
    public static void main(String [] args){    
        for(int y = 0; y < 4; y++){
//            System.out.print("Y"+y);
            for(int x = 3; x > (y); x--){
                if(y != 0){
                    System.out.print("* ");
                }
                
            }   
            
            for(int a = 0; a < y; a++){
                System.out.print("# ");
            }
            for(int a = 1; a < y; a++){
                System.out.print("# ");
            } 
            
            for(int x = 3; x > (y); x--){
                if(y != 0){
                    System.out.print("* ");
                }
            } 
            
            System.out.println();
        }
    }
}