st=[0]*10
cnt,top=0,-1
s=input( )
for i in range(0,len(s),2):
t=s[i]
n=int(s[i+1])
if t=='A':
for j in range(n):
top+=1
st[top]=cnt
cnt+=1
elif t==’P’:
while top!=-1 and n>0:
top-=1
n-=1
print(st[0:top+1])
若输入s的值为"A1P2A3P2A2",则程序的输出结果是( )
A.[5,6] | B.[2,5,6] | C.[4,5] | D.[1,4,5] |
同类型试题
y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2
y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2