加载错误 @ 2023-03-13 23:37:43
s = input()
#print(s[0:1],s[2:5],s[6:11],s[12:13])
t = (int(s[0:1]) * 1 + int(s[2:3]) * 2 + int(s[3:4]) * 3 + int(s[4:5]) * 4 + int(s[6:7]) * 5 + int(s[7:8]) * 6 + int(s[8:9]) * 7 + int(s[9:10]) * 8 + int(s[10:11]) * 9) % 11
if t == 10:
if s[12:13] == 'X':
print("Right")
else:
print(s[0:12],end = '')
print('X')
else:
if int(s[12:13]) == t:
print("Right")
else:
print(s[0:12], end='')
print(t)
by fchwpo @ 2023-03-14 09:07:06
s = input()
#print(s[0:1],s[2:5],s[6:11],s[12:13])
t = (int(s[0:1]) * 1 %11+ int(s[2:3]) * 2 %11+ int(s[3:4]) * 3 %11+ int(s[4:5]) * 4 %11+ int(s[6:7]) * 5 %11+ int(s[7:8]) * 6 %11+ int(s[8:9]) * 7 %11+ int(s[9:10]) * 8 %11+ int(s[10:11]) * 9 %11) % 11
if t == 10:
if s[12:13] == 'X':
print("Right")
else:
print(s[0:12],end = '')
print('X')
else:
if(s[12:13]== 'X'):
print(s[0:12], end='')
print(t)
elif int(s[12:13]) == t:
print("Right")
else:
print(s[0:12], end='')
print(t)
by KSS_IS_BIG_SB @ 2023-03-14 09:12:49
倒数第五行的if
判断有问题,如果s[12:13]
恰好等于X
的话,用int()
转换类型是会报错的
可以改成这样,就能过了
if s[12:13] == str(t):
print("Right")
因为在这里t
不会等于10,所以s[12:13]
等于'X'
的情况肯定是错误的,就不用再考虑把'X'
转成10比较了