結果
問題 | No.227 簡単ポーカー |
ユーザー |
![]() |
提出日時 | 2015-06-20 08:16:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 768 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 58,960 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 15:08:23 |
合計ジャッジ時間 | 989 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
コンパイルメッセージ
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; } else { cout << "NO HAND" << endl; } return 0; }