Skip to content

Instantly share code, notes, and snippets.

@mattn
Forked from yusukebe/gist:324485
Created March 8, 2010 01:19
Show Gist options
  • Save mattn/324765 to your computer and use it in GitHub Desktop.
Save mattn/324765 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef enum { GU = 1, CHOKI = 2, PA = 3 } HAND;
void judge(HAND handA, HAND handB);
int
main(void) {
judge(GU, GU);
judge(GU, CHOKI);
judge(GU, PA);
puts("");
judge(CHOKI, GU);
judge(CHOKI, CHOKI);
judge(CHOKI, PA);
puts("");
judge(PA, GU);
judge(PA, CHOKI);
judge(PA, PA);
}
void
judge(HAND myhand, HAND yourhand) {
switch ((myhand - yourhand + 3) % 3) {
case 0: printf("あいこだよん\n"); break;
case 1: printf("あなたの負け\n"); break;
case 2: printf("あなたの勝ち\n"); break;
default:
// http://t2.gstatic.com/images?q=tbn:l-fSJIgOZLWoeM:http://blog-imgs-31-origin.fc2.com/s/m/o/smokie/luck.jpg
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment