题解 | 【模板】序列操作
【模板】序列操作
https://www.nowcoder.com/practice/12da4185c0bb45918cfdc3072e544069
import sys
q=int(input())
l=[]
for i in range(0,q):
s=list(map(int,input().split(' ')))
if s[0] ==1:
l.append(s[1])
if s[0] ==2:
l.pop(-1)
if s[0] ==3:
print(l[s[1]])
if s[0] ==4:
l.insert(s[1]+1,s[2])
if s[0] ==5:
l.sort()
if s[0] ==6:
l.sort()
l.reverse()
if s[0] ==7:
print(len(l))
if s[0] ==8:
for j in range(len(l)):
print(l[j],end=' ')
print()
查看4道真题和解析