C语言代码实现剪刀石头布游戏
#include <stdio.h>
#include <string.h>
int main() {
int n, x, y;
scanf("%d", &n);
char alice[10], bom[10];
for (int i = 0; i < n; i++) {
scanf("%s %s", alice, bom);
if (strcmp(alice, "B") == 0)
x = 0;
else if (strcmp(alice, "J") == 0)
x = 1;
else
x = 2;
if (strcmp(bom, "B") == 0)
y = 0;
else if (strcmp(bom, "J") == 0)
y = 1;
else
y = 2;
if (x == y) {
printf("平\n");
continue;
} else if (x == (y + 1) % 3) {
printf("alice\n");
} else {
printf("bom\n");
}
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/O89 著作权归作者所有。请勿转载和采集!