47 lines
669 B
C
47 lines
669 B
C
#include <stdio.h>
|
|
|
|
#define ROCK 1
|
|
#define PAPER 2
|
|
#define SCISSORS 3
|
|
|
|
int norm_symb(char s) {
|
|
int r = (int) s - 0x40;
|
|
|
|
if (r > 3 ) {
|
|
r -= 0x17;
|
|
}
|
|
return r;
|
|
}
|
|
|
|
int score(int p1, int p2) {
|
|
if (p1 == p2) {
|
|
return 3;
|
|
}
|
|
|
|
switch (p2) {
|
|
case ROCK:
|
|
if (p1 == SCISSORS) return 6;
|
|
break;
|
|
case PAPER:
|
|
if (p1 == ROCK) return 6;
|
|
break;
|
|
case SCISSORS :
|
|
if (p1 == PAPER) return 6;
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int main () {
|
|
char cur[20];
|
|
int p1;
|
|
int p2;
|
|
int sc = 0;
|
|
while (fgets(cur,20,stdin) != NULL) {
|
|
p1 = norm_symb(cur[0]);
|
|
p2 = norm_symb(cur[2]);
|
|
printf("%d %d %d\n", p1,p2, score(p1,p2));
|
|
sc += (score(p1,p2) + p2);
|
|
}
|
|
printf("%d\n", sc);
|
|
}
|