题型:综合题 题类:模拟题 难易度:普通
浙江省名校信息技术仿真训练卷(一)
程序代码如下,为实现上述功能,请在画线处填写合适的代码。
Dim bh(10 000)As String ‘存储学生编号
Dim jf(10 000)As Integer ‘存储学生获得的积分值
Dim n As Integer ‘存储学生总人数
Function Search(x As Integer)As Integer
Search=0
i=1:j=n:flag=True
Do While i<=j And flag=True
m=Int((i+i)/2)
If x=jf(m) Then
flag=False
①
Elself ② Then
i=m+1
Else
j=m-1
EndIf
Loop
End Function
Private Sub Form_Load()
‘从数据库中读取学生编号和积分,分别存储到bh数组和jf数组中,并按积分值从小到大排序,显示在列表框List1中
End Sub
Private Sub Command1_Click()
Dim Top As Integer,Bottom As Integer,Topxb As Integer,Bottomxb
As Integer
List2.Clear
Top=Val(Text1.Text)
Bottom=Val(Text2.Text)
If Top>Bottom Then t=Top:Top=Bottom:Bottom=t
If Top>jf(n)Or Bottom<jf(1)Then Exit Sub
Do While Search(Top)=0
Top=Top+1
Loop
Do While Search(Bottom)=0
Bottom=Bottom-1
Loop
Topxb=Search(Top)
Do While jf(Topxb)=jf(Topxb-1)And Topxb>l
Topxb=Topxb-1
Loop
Bottomxb=Search(Bottom)
Do While jf(Bottomxb)=jf(Bottomxb+1)And Bottomxb<n
Bottomxb=Bottomxb+1
Loop
For i= ③
List2.AddItem bh(i)&" "&jf(i)
Next i
End Sub
① ② ③
def dele(a, head):
pre=head; p=a[head][1]
while p!=-1:
q=head
flag=False
|
if a[q][0]==a[p][0]:
|
p=a[p][1]
flag=True
break
q=a[q][1]
if not flag:
pre=p;
p=a[p][1]
a=[[0, 3], [1, 2], [1, 4], [0, 1], [0, 5], [2, -1]]
dele(a, 0)
①q!=-1 ②q!=p ③a[pre][1]=a[p][1] ④a[pre][1]=a[q][1]
方框中填入的正确代码依次为( )
试题篮