python 12.py [2,5,4,3,1]是[1,2,3,4,5]的出栈序列 python 12.py [5,2,3,1,4]不是[1,2,3,4,5]的出栈序列 |
图2
def judge(a,b):
n=len(a);st=[-1] *n
top=-1;i=j= 0
while i<n:
top+=1
①
i+=1
while top>-1 and ② :
top-=1
j+=1
return top==-1
from random import shuffle
a=[1,2,3,4,5]
b=[1,2,3,4,5]
shuffle(b) #将序列b的元素随机排序
if judge(a,b):
print(b,'是',a,'的出栈序列')
else:
print(b,'不是',a,'的出栈序列')
程序运行结果如第12题图所示。划线处应填写的语句是
A.①st[top]=a[i] ②st[top]==b[j] | B.①st[top]=a[i] ②st[-1]==b[j] |
C.①st[top]=b[i] ②st[top]=a[j] | D.①st[top]=b[i] ②st[-1]==a[j] |

同类型试题

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

