C++

[C++] 042 피라미드 (for)

qkrwngus 2021. 3. 22. 21:25

Desc :

 

 


Source Code :

#include <iostream>

using namespace std;

int main()
{
	char ch = '*';

	int offset = 4;

	for (int i = 1, j=0; i<= offset; i++,j=0)
	{
		for (int k=1; k <= offset -i ; k++)	// 좌측에 공백 출력
			cout << " ";

		while (j != 2 * i - 1)			
		{
			cout << "*";
			j++;
		}

		cout << endl;
	}
}

 


Result :