結果
| 問題 |
No.227 簡単ポーカー
|
| コンテスト | |
| ユーザー |
tntan
|
| 提出日時 | 2015-06-20 08:14:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 727 bytes |
| コンパイル時間 | 446 ms |
| コンパイル使用メモリ | 59,684 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 15:08:21 |
| 合計ジャッジ時間 | 988 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:36: warning: iteration 4 invokes undefined behavior [-Waggressive-loop-optimizations]
15 | if (a[i] == a[i + 1])
| ~~~~~~~^
main.cpp:13:27: note: within this loop
13 | for (int i = 0; i < 5; i++)
| ~~^~~
ソースコード
#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;
}
return 0;
}
tntan