Skip to content

Instantly share code, notes, and snippets.

@chomado
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chomado/11393284 to your computer and use it in GitHub Desktop.
Save chomado/11393284 to your computer and use it in GitHub Desktop.
/* 現在は修正されています
前: scanf("%c %d", &mark, &num);
後: scanf(" %c %d", &mark, &num);
*/
#include <stdio.h>
void check(int);
void print(void);
int mark_to_id(char mark);
/************ メイン関数 ***********/
int main(void)
{
int max;
scanf("%d", &max);
check(max);
print();
return 0;
}
/************ 関数群 **************/
char marks[5] = "SHCD";
int cards[4][14]; // 持っていたら1, 持っていなかったら0が格納される
int mark_to_id(char mark)
{
int id;
for (id=0; id<4; id++)
if (mark == marks[id]) return id;
return -1;
}
char id_to_mark(int id)
{
return marks[id];
}
void check(int max)
{
int i;
char mark;
int num;
for (i=0; i<max; i++) {
scanf(" %c %d", &mark, &num);
cards[mark_to_id(mark)][num] = 1;
}
}
void print(void)
{
int i, j;
for (i=0; i<4; i++)
for (j=1; j<=13; j++)
if (!cards[i][j]) printf("%c %d\n", id_to_mark(i), j);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment