View Code of Problem 53

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner  scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int index = 1;
		int temp = a;
		for (; temp > 1; temp--) {
			for (int j = temp; j > 1; j--) {
				System.out.print(" ");
			}
			for (int j = 0; j < index; j++) {
				
				System.out.print("*");
			}
			index += 2;
			System.out.println();
		}
		for (int i = 0; i < index; i++) {
			System.out.print("*");
		}
		System.out.println();
		int tap =0;
		for (;tap < a;tap++) {
			for (int i = -1;i < tap;i++) {
				System.out.print(" ");
			}
			for (int i = index-2; i > 0; i--) {
				System.out.print("*");
			}
			index -=2;
			System.out.println();
		}
		
		
		
		
	}
}

Double click to view unformatted code.


Back to problem 53