题解 | 【模板】序列操作

【模板】序列操作

https://www.nowcoder.com/practice/12da4185c0bb45918cfdc3072e544069

q = int(input())
result = []
for i in range(q):
    l = list(map(int,input().split()))
    if l[0]==1:
        result.append(l[1])
    elif l[0]==2:
        if result:
            result.pop()
    elif l[0]==3:
        print(result[l[1]])    
    elif l[0]==4:
        result.insert(l[1]+1,l[2])
    elif l[0]==5:
        result.sort()
    elif l[0]==6:
        result.sort(reverse = True)
    elif l[0]==7:
        print(len(result))
    elif l[0]==8:
        print(*result)

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务