1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【额外练习】选择结构/7-31 选择-猜数字游戏.c

30 lines
586 B
C

#include <stdio.h>
int main() {
int total, andy, ban;
scanf("%d%d%d", &total, &andy, &ban);
int andyDiff = total - andy;
int banDiff = total - ban;
if (andyDiff < 0) andyDiff = -andyDiff;
if (banDiff < 0) banDiff = -banDiff;
if (andyDiff == banDiff) {
if (andy < ban) {
printf("Andy\n");
} else if (andy == ban) {
printf("Peace\n");
} else {
printf("Ban\n");
}
} else if (andyDiff < banDiff) {
printf("Andy\n");
} else {
printf("Ban\n");
}
return 0;
}