結果

問題 No.227 簡単ポーカー
ユーザー PraiPrai
提出日時 2018-02-20 02:22:00
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 30,036 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-23 03:54:48
合計ジャッジ時間 1,227 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:19:20: 警告: iteration 4 invokes undefined behavior [-Waggressive-loop-optimizations]
   19 |                 B[A[i]]++;
      |                   ~^~~
main.c:16:27: 備考: within this loop
   16 |         for (int i = 1; i <= 5; ++i)
      |                         ~~^~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(int argc, char const *argv[])
{	
	int A[5],B[14];
	int three_card=0,pair=0;

	for (int i = 1; i <= 13; ++i)
	{
		B[i]=0;
	}

	for (int i = 1; i <= 5; ++i)
	{
		scanf("%d",&A[i]);
		B[A[i]]++;
	}

	for (int i = 1; i <= 13; ++i)
	{
		if(B[i]==3){
			three_card=1;
		}else if(B[i]==2){
			pair++;
		}
	}

	if(three_card==1 && pair==1){
		printf("FULL HOUSE\n");
	}else if(three_card==1){
		printf("THREE CARD\n");
	}else if(pair==2){
		printf("TWO PAIR\n");
	}else if(pair==1){
		printf("PAIR\n");
	}else{
		printf("NO HAND\n");
	}
	
	return 0;
}
0