问题 4477 --数组元素的删除

4477: 数组元素的删除★★

时间限制: 1 Sec  内存限制: 128 MB
提交: 242  解决: 188
[提交][状态][命题人:]

题目描述

把一个数组的第x个位置的元素删除掉

【Python】

n=int(input())
a=input().split()
x=int(input())

linked=[]
for i in range(n-1):
    node=[a[i],i+1]
    linked.append(node)
node=____(1)_______
linked.append(node)


head=_____(2)______
if x==1:
    node=linked[head]
    head=_____(3)______
else:
    next=head
    s=1
    while next !=-1 and s<x-1:
         next=_____(4)_______                                                                                                                                                          
         s+=1
    node=linked[next]
    node[1]=______(5)________
    
next=head
while next!=-1:
    node=linked[next]
    print(node[0],end=' ')
    next=node[1]

输入

有三行

第一行有一个整数n( n <= 100 )

第二行有n个整数

第三行有一个整数x,为要删除的位置

输出

输出更新后的数组

样例输入
Copy
5
1 2 3 4 5 
3
样例输出
Copy
1 2 4 5

提示

来源

SZS 

[提交][状态]