heyongheng_20242782 @ 2024-10-04 18:21:38
n=list(map(int,input().split()))
m=input()
n.sort()
for i in range(len(m)):
if i!=len(m)-1:
if m[i]=="A":
print(n[0],end=" ")
elif m[i]=="B":
print(n[1],end=" ")
else:
print(n[2],end=" ")
else:
if m[i]=="A":
print(n[0])
elif m[i]=="B":
print(n[1])
else:
print(n[2])
求求各位大哥解惑,谢谢了
by NC20061226 @ 2024-10-04 18:38:45
@gousheng123 不用这么麻烦,其实你可以这么写
l1 = list(map(int,input().split()))
l1.sort()
str1 = input()
for i in range(3):
if(str1[i]=='A'):
print(l1[0],end=' ')
elif(str1[i]=='B'):
print(l1[1],end=' ')
else:
print(l1[2],end=' ')
by heyongheng_20242782 @ 2024-10-04 19:53:17
@NC20061226 我终于知道哪里错了,我把len(m)改成3就对了,也就是说它其实输入的ABC后面还有某种符号,导致我的输出变长了(多了几个else的print),所以一直报错too long