문제 : https://www.acmicpc.net/problem/10990


[ 알고리즘풀이 ]

 규칙파악문제

#include<iostream>

using namespace std;

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N + i; j++) {
			if (j == (N - i - 1) || j == (N + i - 1))
				cout << '*';
			else
				cout << ' ';
		}
		cout << '\n';
	}
	return 0;
}

 

+ Recent posts