题型:综合题 题类:常考题 难易度:普通
浙江省高中信息技术 查找算法及程序实现同步练习
请回答下列问题:
Const maxn=10
Dim a(1 To maxn) As Integer
Private Sub Form_Load()
‘maxn个数据存储在数组a中,并在列表框List1中显示
‘代码略
End Sub
Private Sub Command1_Click()
Dim i As Integer, n As Integer ‘n用于存储当前査找的数组长度
Dim j As Integer, key As Integer ‘key用于存储本次查找关键字的数据位置
key=1: n=maxn
Do While key <=n
i=n
Do While a(i) <> a(key)
Loop
If i=key Then ‘未找到,重新下一査找关键字
key=key+1
Else ‘找到重复数据,删除
For j=i To n-1
Next j
n=n-1
End If
Loop
For i=1 To n
List2.AddItem Str(a(i))
Next i
Label1.Caption=“共删除数据”++“个”
End Sub
list1=[“welcome”,“to”,“Python”,“World”] print(list1[2]) |
试题篮