#include <stdio.h>
int card[14][5];
void init(void)
{
int i, j;
for (i = 0; i < 14; i++)
{
for (j = 0; j < 5; j++)
{
card[i][j] = 0;
}
}
}
void check_card(char ch, int num)
{
int m;
if (ch == 'S') m = 1;
else if (ch == 'D') m = 2;
else if (ch == 'H') m = 3;
else m = 4;
card[num][m] = 1;
}
int check_straight(int type)
{
int i, j;
int sum = 0;
for (i = 1; i <= 9; i++)
{
sum = 0;
for (j = 0; j < 5; j++)
{
if (card[i + j][type])
{
sum++;
}
}
if (sum >= 5)
{
return 1;
}
}
sum = 0;
for (j = 10; j < 14; j++)
{
if (card[j][type])
sum++;
}
if (card[1][type]) sum++;
if (sum == 5) return 1;
return 0;
}
void check_result(void)
{
int i, j;
int is_flush = 0;
int is_poker = 0;
int count_3 = 0;
int count_2 = 0;
for (i = 1; i < 14; i++)
{
card[0][1] += card[i][1];
card[0][2] += card[i][2];
card[0][3] += card[i][3];
card[0][4] += card[i][4];
}
for (i = 1; i < 14; i++)
{
for (j = 1; j <= 4; j++)
{
card[i][0] += card[i][j];
}
}
for (i = 1; i <= 13; i++)
{
if (card[i][0] == 4)
{
is_poker = 1;
printf("4 Card");
return;
}
}
if (card[0][1] > 4)
is_flush = 1;
else if (card[0][2] > 4)
is_flush = 2;
else if (card[0][3] > 4)
is_flush = 3;
else if (card[0][4] > 4)
is_flush = 4;
if (is_flush)
{
if (check_straight(is_flush))
{
printf("Straight Flush");
return;
}
else
{
printf("Flush");
return;
}
}
if (check_straight(0))
{
printf("Straight");
return;
}
for (i = 1; i < 14; i++)
{
if (card[i][0] == 3) count_3++;
if (card[i][0] == 2) count_2++;
}
if (count_3 == 2 || (count_3 == 1 && count_2 > 0))
{
printf("Full House");
return;
}
if (count_3 > 0 && count_2 == 0)
{
printf("Triple");
return;
}
if (count_2 >= 2 && count_3 == 0)
{
printf("2 Pair");
return;
}
if (count_2 > 0 && count_3 == 0)
{
printf("1 Pair");
return;
}
printf("Top");
}
int main(void)
{
int test_case;
int T;
int N;
int i, j;
char ch[2];
int num;
freopen("input.txt", "r", stdin);
setbuf(stdout, NULL);
scanf("%d", &T);
for (test_case = 1; test_case <= T; ++test_case)
{
init();
for (j = 0; j < 7; j++)
{
scanf("%s %d", ch, &num);
check_card(ch[0], num);
}
printf("#%d ", test_case);
check_result();
printf("\n");
}
return 0; //정상종료시 반드시 0을 리턴해야 합니다.
}
댓글