프로그래밍으로 만든 장난감들

[C#] CheckPattern 별찍기 생성기

이족보행달팽이 2024. 10. 22. 08:28

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hello_World
{
class Program
{
    static void Main(string[] args)
    {
        int n = 6;
        int m = 6;

        int PatternWidth = n * m;
        int PatternSize = PatternWidth* PatternWidth;
            
        for(int i=0;i<PatternSize; i++)
        {
            if((i/ n)%2 == 0)
            {
                if (i / PatternWidth / n % 2 == 0)
                {
                    Console.Write("◆");
                }
                else
                {
                    Console.Write("■");
                }
            }
            else if((i/ n)%2 == 1)
            {
                if (i / PatternWidth / n % 2 == 0)
                {
                    Console.Write("■");
                }
                else
                {
                    Console.Write("◆");
                }
            }

            if (i % PatternWidth == PatternWidth-1)
            {
                Console.WriteLine();
            }
        }
    }
}
}

 

 

'프로그래밍으로 만든 장난감들' 카테고리의 다른 글

2D 게임  (0) 2025.02.08
[JS] 분수 파티클  (3) 2024.10.22