View Code of Problem 53

import java.util.Scanner;

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

Double click to view unformatted code.


Back to problem 53