結果

問題 No.227 簡単ポーカー
ユーザー monburan_0401monburan_0401
提出日時 2018-09-09 22:52:45
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,252 bytes
コンパイル時間 1,125 ms
コンパイル使用メモリ 29,052 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 22:36:13
合計ジャッジ時間 1,570 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,384 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
int main(void){
	int A[5];
	int change;
	int a = 0;
	int count = 1;
	int pair = 0;
	int threecard = 0;
	
	for(int i = 0; i < 5; i++){
		scanf("%d",&A[i]);
	}
	
	// sort
	for(int k = 0; k < 4; k++){
		for(int l = k; l < 5; l++){
			if(A[k] > A[l]){
				change = A[k];
				A[k] = A[l];
				A[l] = change;
			}
		}
	}
	
	//	check ok
/*	for(int m = 0; m < 5; m++){
		printf("%d ",A[m]);
	}
	printf("\n");
*/
	
	//	search
	for(int j = 1; j < 5; j++){
		if(A[a] == A[j]){
			count++;
		//	printf("count = %d\n",count);
		}else{
			a = j;
			if(count == 2){
				pair++;
			//	printf("pair = %d\n",pair);
			}else if(count == 3){
				threecard++;
			//	printf("threecard = %d\n",threecard);
			}
			count = 1;
		}
	}
	if(count == 2){
		pair++;
	//	printf("pair = %d\n",pair);
	}else if(count == 3){
		threecard++;
	//	printf("threecard = %d\n",threecard);
	}
	// judge
	if((pair == 0)&&(threecard == 0)){
		printf("NO HAND\n");
		return 0;
	}
	else {
		// result
		if((pair == 1)&&(threecard == 1)){
			printf("FULL HOUSE\n");
			return 0;
		}else if(pair == 2){
			printf("TWO PAIR\n");
			return 0;
		}else if(threecard == 1){
			printf("THREE CARD\n");
			return 0;
		}else{
			printf("ONE PAIR\n");
			return 0;
		}
	}
	
	return 0;
}
0