結果
| 問題 |
No.227 簡単ポーカー
|
| コンテスト | |
| ユーザー |
jokin_tokei
|
| 提出日時 | 2017-09-07 04:50:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,302 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 24,448 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 10:51:33 |
| 合計ジャッジ時間 | 776 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘void poker()’:
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d %d %d %d %d", &cards[0], &cards[1], &cards[2], &cards[3],
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 | &cards[4]);
| ~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#define ARRAY_NUM 100000
void jenga(); //
void poker();
int main(void) {
poker();
return 0;
}
void poker() {
int i, j, same_num, max_same_num, min, temp, second_same_num, pair_num;
int cards[5] = { };
i = j = max_same_num = same_num = second_same_num = pair_num = min = 0;
scanf("%d %d %d %d %d", &cards[0], &cards[1], &cards[2], &cards[3],
&cards[4]);
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (cards[i] > cards[j]) {
temp = cards[i];
cards[i] = cards[j];
cards[j] = temp;
}
}
}
// int debug = 0;
// while (debug++ < 5) {
// printf("%d ",cards[debug-1]);
// }
for (i = 0; i < 4; i++) {
if (cards[i] == cards[i + 1]) {
same_num++;
pair_num++;
max_same_num = max_same_num > same_num ? max_same_num : same_num;
} else {
same_num = 0;
}
}
if ((cards[0] == cards[1]) && (cards[3] == cards[4])) {
second_same_num++;
}
switch (max_same_num) {
case 0:
printf("NO HAND\n");
break;
case 1:
if (pair_num == 1) {
printf("ONE PAIR\n");
} else {
printf("TWO PAIR\n");
}
break;
case 2:
if (second_same_num == 0) {
printf("THREE CARD\n");
} else {
printf("FULL HOUSE\n");
}
break;
case 3:printf("THREE CARD\n"); break;
case 4:printf("THREE CARD\n");
}
}
jokin_tokei