윷놀이판 만들기

강kang·2024년 12월 23일

using System;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Security.Authentication;
using static System.Console;

namespace Hello
{
class MainApp
{
//프로그램 실행이 시작되는 곳
static void Main(string[] args)
{
int input1 = Convert.ToInt32(Console.ReadLine());

        for(int i = 0; i < input1; i++)
        {
            for (int j = 0; j < input1; j++) // 0, 1, 2, 3, 4 < 5
            {
                if (i == 0 || i == input1 - 1) // 상단, 하단
                {
                    Console.Write("*");
                }
                else if (j == 0) // 좌단
                {
                    Console.Write("*");
                }
                else if (j == input1 - 1) // 우단
                {
                    Console.Write("*");
                }
                else // 테두리가 아닐때
                {
                    if (i == j) // 우향 대각선
                    {
                        Console.Write("*");
                    }
                    else if (input1 - i - 1 == j) // 좌향 대각선
                    {
                        Console.Write("*");
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
            }
            Console.WriteLine();
        }
    }
}

}

profile
코딩

0개의 댓글