끄적끄적 코딩
article thumbnail

별 찍기 문제입니다.

n-i의 공백이 있으며,
현재 줄 만큼의 별을 출력합니다.

#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, char* argv[])
{
	int n;

	cin >> n;

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n - i; ++j) {
			cout << " ";
		}
		
		for (int j = 1; j < i; ++j) {
			cout << "* ";
		}
		cout << "*\n";
	}

	return 0;
}

검색 태그