题型:填空题 题类:常考题 难易度:普通
高中信息技术——排序算法及程序实现(浙江专用)
实现上述功能的VB程序如下,但加框处代码有错,请改正。
Const n = 10
Dim a(1 To n)As Integer
Private Sub Commandl_Click()
Dim i As Integer,j As Integer,t As Integer
Dim bottom As Integer
'获取排序前数据依次存储在数组a中,并在文本框Text 1中显示。代码略
bottom = n
i = 1
Do While i<= bottom-1
For j = bottom To i + 1 Step -1
If Then ‘⑴
t = a(j): a(j)= a(j - 1):a(j - 1)= t
Elself a(j)= a(j - 1)Then '相邻两个数据相等,进行剔除处理
‘⑵
bottom = bottom -1
End If
Next j
i = i+1
Loop
Text2.Text=""
For i = 1 To bottom
Text2.Text = Text2.Text+Str(a(i))
Next i
End Sub
⑴ ⑵
输入2350123456783,先将字符串拆成三段,分别是235,012345678,3要求每一段必须严格有序,如果无法实现连续升序,则单独作为一个拆分。
原字符串 | 235 | 012345678 | 3 | |||
连续升序字符数 | 3 | 9 | 1 | |||
密文 | 235 | 3 | 012345678 | 9 | 3 | 1 |
在文本框Text1中输入原文,单击“加密”按钮,可在文本框Text2中输出密文。
在文本框Text2中输入密文,单击“解密”按钮,可在文本框Text3中输出原文。
a=[20,32,56,12,48] maxx=a[0] for k in ①: if maxx<k: ② print( ③ ) |
试题篮