ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 10991번 , 10992번
    백준알고리즘/입출력 2020. 10. 2. 17:24

    10991번

    #include<iostream>
    using namespace std;
    
    int main()
    {
    	int cnt;
    	int n;
    	cin >> n;
    	cnt = 1;
    	for (int i = 0; i < n; i++)
    	{
    		for (int j = n - 1; j > i; j--)
    		{
    			cout << ' ';
    		}
    		for (int j = 0; j < cnt; j++)
    		{
    			if (j % 2 == 0)
    			{
    				cout << '*';
    			}
    			else
    			{
    				cout << ' ';
    			}
    			
    		}
    		cnt = cnt + 2;
    		cout << '\n';
    	}
    	
    }

     

    10992번

    #include<iostream>
    using namespace std;
    
    int main()
    {
    	int cnt;
    	int n;
    	cin >> n;
    	cnt = 1;
    	for (int i = 0; i < n; i++)
    	{
    		for (int j = n - 1; j > i; j--)
    		{
    			cout << ' ';
    		}
    		for (int j = 0; j < cnt; j++)
    		{
    			if (i == n - 1)
    			{
    				cout << '*';
    			}
    			else
    			{
    				if (j == 0 || j==cnt-1)
    				{
    					cout << '*';
    				}
    				else
    				{
    					cout << ' ';
    				}
    			}
    			
    			
    		}
    		cnt = cnt + 2;
    		cout << '\n';
    	}
    	
    }

    '백준알고리즘 > 입출력' 카테고리의 다른 글

    2446번  (0) 2020.10.02
    2442번, 2445번  (0) 2020.10.02
    2439번, 2440번, 2441번  (0) 2020.10.02
    8393번, 10818번, 2438번  (0) 2020.10.02
    1924번  (0) 2020.10.02
Designed by Tistory.