結果

問題 No.227 簡単ポーカー
ユーザー shirano_cshirano_c
提出日時 2017-11-02 14:06:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 2,741 bytes
コンパイル時間 4,135 ms
コンパイル使用メモリ 101,280 KB
実行使用メモリ 22,880 KB
最終ジャッジ日時 2023-08-14 15:19:26
合計ジャッジ時間 3,557 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,792 KB
testcase_01 AC 56 ms
22,764 KB
testcase_02 AC 56 ms
18,736 KB
testcase_03 AC 55 ms
18,628 KB
testcase_04 AC 55 ms
20,732 KB
testcase_05 AC 56 ms
22,772 KB
testcase_06 AC 55 ms
20,856 KB
testcase_07 AC 56 ms
18,628 KB
testcase_08 AC 56 ms
18,860 KB
testcase_09 AC 56 ms
20,736 KB
testcase_10 AC 56 ms
20,904 KB
testcase_11 AC 55 ms
20,780 KB
testcase_12 AC 56 ms
18,700 KB
testcase_13 AC 56 ms
22,880 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace simplepoker
{
    class Program
    {
        static void Main()
        {
            string nums = Console.ReadLine();
            string[] nospaceNums = nums.Split(' ');
            int[] cards = new int[5];
            int first, end, temp = 0;
            //int配列の中にstring配列の中身を入れる
            for (int i = 0; i < nospaceNums.Length; i++)
            {
                cards[i] = Convert.ToInt32(nospaceNums[i]);
            }
            //cards配列の中身をバブルソート
            for (first = 0; first < cards.Length; first++)
            {
                for (end = cards.Length - 1; end > first; end--)
                {
                    if (cards[end] < cards[end - 1])
                    {
                        temp = cards[end - 1];
                        cards[end - 1] = cards[end];
                        cards[end] = temp;
                    }
                }
            }

            //A1とA5が一致する場合は5カード
            //A1とA4が云々
            if (cards[0] == cards[4])
                Console.WriteLine("NO HAND");
            else if (cards[0] == cards[3])
                Console.WriteLine("NO HAND");
            //A1A4
            else if (cards[0] == cards[2])
            {
                //A4A5が同じか
                if (cards[3] == cards[4])
                {
                    Console.WriteLine("FULL HOUSE");
                    return;
                }
                Console.WriteLine("THREE CARD");
            }
            else if (cards[2] == cards[4])
            {
                if (cards[0] == cards[1])
                {
                    Console.WriteLine("FULL HOUSE");
                    return;
                }
                Console.WriteLine("THREE CARD");
            }
            //A1A2が同じか
            else if (cards[0] == cards[1])
            {
                //A3A4が同じか
                if (cards[2] == cards[3])
                {
                    Console.WriteLine("TWO PAIR");
                    return;
                }
                Console.WriteLine("ONE PAIR");
            }
            //A1A2が同じか
            else if (cards[1] == cards[2])
            {
                //A3A4が同じか
                if (cards[3] == cards[4])
                {
                    Console.WriteLine("TWO PAIR");
                    return;
                }
                Console.WriteLine("ONE PAIR");
            }

            else if (cards[2] == cards[3]||cards[3]==cards[4])
                Console.WriteLine("ONE PAIR");
            else
                //ブタ
                Console.WriteLine("NO HAND");
        }
    }
}
0