PAT基础 7-9 用天平找小球 python实现
三个球A、B、C,大小形状相同且其中有一个球与其他球重量不同。要求找出这个不一样的球。
输入格式:
输入在一行中给出3个正整数,顺序对应球A、B、C的重量。
输出格式:
在一行中输出唯一的那个不一样的球。
输入样例:
1 1 2
输出样例:
C
注释:这个代码包括了所有情况
def checkball(a,b,c):
if a == b:
if c != a:
print(“C”)
else:
print(“the same”)
elif a == c:
if b != a:
print(“B”)
else:
print(“the same”)
elif b == c:
if a != b:
print(“C”)
else:
print(“the same”)
else:
print(“all the different”)