結果
問題 |
No.227 簡単ポーカー
|
ユーザー |
![]() |
提出日時 | 2015-06-20 08:12:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 716 bytes |
コンパイル時間 | 495 ms |
コンパイル使用メモリ | 58,968 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 15:08:20 |
合計ジャッジ時間 | 1,011 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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) { 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; }