1. 2022 8 Z20 3
1
A
B
C Excel
D
2. 2022 9 9
2.
A.
B.
C.
D.
3. 2022 10 10
3.
A.
B.
C.
D. “ ”
4. 2022 10 12
4.
def travel(lnk,head):
p=head
s = ""
while ______ ______:
s += str(lnk[p][0])+"->"
p = lnk[p][1]
s += str(lnk[p][0])
print(s)
4
user= [[7,2],[15,0],[5,3],[1,-1]]
head = 1
num = int(input(" :").strip())
p=head
if head==-1 or num>user[p][0]:
user.append([num,head])
head=len(user)-1
else:
while user[p][1]!=-1 and ______ ______:
p=user[p][1]
user.append([num,user[p][1]])
______ ______
travel(user,head)
4
A. B.
lnk[p][1]!=-1 lnk[p][1]!=-1
1/5
num<=user[p][0] num<=user[user[p][1]][0]
user[p][1]=len(user)-1 user[p][1]=len(user)-1
C. D.
p!=-1 p!=-1
num<=user[user[p][1]][0] num<=user[p][0]
user[p][1]=len(user)-1 user[p][1]=len(user)
5. 2022 11 12
5.
a
import math
-
head=0 ; s=0
p=a[head][3]
while (1) :
s+=math. sqrt((a[p][1]-a[head][1])**2+(a[p][2]-a[head][2])**2)
(2)
(3)
print(s)
a[head][3]!=-1 head=p p=a[head][3] head!=-1
(1) (2) (3)
A. B. C. D.
6. 2022 11 8
6. 6 a
6 a 6 b
“ ” “ ” “ ” 6 b
“ ” next “ ” next
“ ” next 5
“ ” next “ ” next
“ ” next -1
A. B. C. D.
7. 2022 11 11
2/5
7.
A B C D E -1
A C E B D -1
# a head
odd = head
even = a[odd][1]
tmp = even
while a[odd][1] != -1 and a[even][1] != -1:
a[odd][1] = tmp
odd = a[odd][1] even = a[even][1] a[odd][1] = a[even][1] a[even][1] =
a[odd][1]
A. B. C. D.
8. 2022 11 10
8. lb
[[“ ”,“13282825678”,280,1],[“
”,“13256787678”,500,3],...] head
phone
p=head
q=p
while p!=-1:
if lb[p][1]==phone:
if p==head:
1
else:
2
q=p
3
head=lb[p][3] p=lb[p][3] lb[p][3]=lb[q][3] lb[q][3]=lb[p][3]
A. B. C. D.
9. 2022 11 9+1 11
9. Python
3/5
a=[[7,3],[5,0],[2,1],[9,-1]]
head=2
key=int(input())
p=q=head
while p!=-1 and a[p][0]q=p
p=a[p][1]
if p==head:
a.append([key,head])
head=len(a)-1
else:
a.append([key,p])
a[q][1]=len(a)-1
print(a[-1])
2
A. [2, -1] B. [2, 1] C. [2, 2] D. [2, 3]
10. 2022 6 8
10. Python p a[p][0] p
a[p][1] p p x x p
A. a[p][1]=x;a[x][1]=a[p][1] B. a[x][1]=a[p][1];a[p][1]=x
C. a[p][0]=x;a[x][0]=a[p][0] D. a[x][0]=a[p][0];a[p][0]=x
11. 2022 11 10
11. a[i][0] i a[i][1] i
p p r r
p pq
a[pq][1] = a[p][1] a[r][1] = p a[p][1] = a[r][1]
A. B. C. D.
12. 2022 11 9
12.
A.
B. n!
C.
D. ( >2)
13. 2022 8
13. Python
a=[[5,-1], [9,4], [7,3], [2, 1], [6, 0]]
head=2
p=head
4/5
b=[]
while a[p][1]!=-1:
b.append(a[p][0])
p=a[p][1]
b.append(a[p][0])
print(b)
程序执行后,输出的结果为:
A. [7,2,9,6,5,5] B. [5,9,7,2,6] C. [7,2,9,6,5] D. [2,9,6]
14.【2022年12月强基联盟信息技术第9题】
14. 采用 Python 二维列表模拟链表,a=[['A', 1], ['B', 2], ['C', 3], ['D', 4], ['E', 5], ['F', -1]]表示链
表为:A→B→C→D→E→F。有以下 Python 程序:
head=0;p=a[head][1]
a[head][1]=-1
while p!=-1:
p=a[p][1]
if p == -1:break
t=a[p][1]
a[p][1]=head
head=p
p=t
执行以上程序后,以 head 为首的链表结构为
A. →C→A B. A→C→E C. →D→F D. F→D→B
5/5
9. 链表及应用
1 2 3 4 5 6 7 8
B D B B A B D C
9 10 11 12 13 14
C B D C C A