結果

問題 No.227 簡単ポーカー
ユーザー tntantntan
提出日時 2015-06-20 08:16:42
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 768 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 61,404 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 21:58:09
合計ジャッジ時間 1,269 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:22: warning: iteration 4 invokes undefined behavior [-Waggressive-loop-optimizations]
   if (a[i] == a[i + 1])
               ~~~~~~~^
main.cpp:13:20: note: within this loop
  for (int i = 0; i < 5; i++)
                  ~~^~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int a[5],count1=0,count2=0,count3=0;
	for (int i = 0; i < 5; i++)
	{
		cin>>a[i];
	}
	sort(a, a + 5);
	for (int i = 0; i < 5; i++)
	{
		if (a[i] == a[i + 1])
		{
			count1++;
		}
		else if (a[i] < a[i + 1])
		{
			count2++;
		}
		if (a[i] == a[i + 1]&&a[i+1] == a[i + 2])
		{
			count3++;
		}
	}
	if (count1 ==0)
	{
		cout << "NO HAND" << endl;
	}
	else if (count1 == 1)
	{
		cout << "ONE PAIR" << endl;
	}
	else if (count1 == 3&&count3==1)
	{
		cout << "FULL HOUSE" << endl;
	}
	else if (count1 == 2 && count2 == 2&&count3==1)
	{
		cout << "THREE CARD" << endl;
	}
	else if (count1 == 2 && count2 == 2)
	{
		cout << "TWO PAIR" << endl;
	}
	else
	{
		cout << "NO HAND" << endl;
	}
	return 0;
}
0