a = [ 5 , 4 , 2 , 1 , 3 , 6 ] ; q = [ 0 ] * 6 ; head = tail = 0
for i in range( len( a ) ):
if a[ i ] % 2 == 1 :
q[ tail ] = a[ i ] ; tail = tail + 1
elif head < tail :
head += 1
print( tail – head )
执行该程序段后,输出结果为( )
微信扫码预览、分享更方便