三个球A、B、C,大小形状相同且其中有一个球与其他球重量不同。要求找出这个不一样的球。
输入格式:
输入在一行中给出3个正整数,顺序对应球A、B、C的重量。
输出格式:
在一行中输出唯一的那个不一样的球。
输入样例:
1 1 2
输出样例:
C
#include <stdio.h>
int main () {
int a, b, c;
int d;
scanf("%d %d %d", &a, &b, &c);
if (a==b) {
d = 3; //第3个不同
} else if (a==c) {
d = 2; //第2个不同
} else if (b==c) {
d = 1; //第1个不同
}
switch (d) {
case 1:
printf("A\n");
break;
case 2:
printf("B\n");
break;
case 3:
printf("C\n");
break;
default:
break;
}
}
题目确实不难,不过感觉还可以优化,后面再搞吧