public class StarTest {

	public static void main(String args[]) {
		int input = 5;
		int st = 0;
		input = (input % 2 == 0) ? input - 1 : input;

		for (int line = 0; line < input; line++) { 
			for (int put = 0; put < (input - st); put++) {
				System.out.print((put >= st) ? "*" : " ");
			}
			st = line < (input / 2) ? st + 1 : st - 1;
			System.out.println();
		}
	}
}

설명



+ Recent posts