본문 바로가기

[자유]Hj

11.17(월)맨시티는레전드조회 303추천수 0댓글수 0


nternal class Program
{
    static int[] DrawDice()
    {
        Random rnd = new Random();
        int[] diceAry = new int[3];

        for (int i = 0; i < diceAry.Length; i++)
            diceAry[i] = rnd.Next(1, 6);

        return diceAry;

        int[] ary;
        ary = DrawDice();

    }
    static void Main(string[] args)
    {
        int[] ary;
        int count = 0;
        while (true)
        {
            count++;
            ary = DrawDice();
            Console.Write("{0}회 던졌음 ==> ", count);
            for (int i = 0; i < ary.Length; i++)
            {
                Console.Write(ary[i] + " ");
            }
            Console.WriteLine();

            Console.Write("계속 진행하시려면 엔터키를 입력하세요.");
            Console.ReadLine();
            if (ary[0] == ary[1] && ary[1] == ary[2])
            {
                Console.WriteLine("3개의 숫자가 맞았습니다.종료합니다.");
                    break; 
            }
            
        }
        }
          
    }

0개의 댓글이 있습니다.

닫기

알림

로그인 후 이용 가능합니다.
로그인하시겠습니까?

알림

게시물이 없습니다.

알림

알림

위로가기