알고리즘 문제/백준

[ C++ ] 별 찍기 10 - 2447

우대비 2022. 11. 11. 14:48
#include <iostream>
using namespace std;

bool check(int size, int i, int j)
{
	if (size <= 0)
		return false;
        
	int _size = size;

	int _y = i % _size;
	int _x = j % _size;
	int _left = (_size / 3) - 1;
	int _right = (_left + 1) * 2;

	if ((_left < _y && _y < _right) && (_left < _x && _x < _right))
	{
		return true;

	}

	else if (check(_size / 3, i, j))
		return true;

	return false;
}

int main()
{
	int size = 0;
	cin >> size;

	for (int i = 0; i < size; i++)
	{
		for (int j = 0; j < size; j++)
		{
			if (check(size, i, j))
				cout << " ";
			else
				cout << "*";
		}
		cout << endl;
	}

	return 0;
}
LIST