随机产生15个A-J的大写字母,按字母降序排序后,将连续出现的字母用压缩的形式显示。例如,连续5个H字母显示为5*H,如图所示,请在划线处填入合适代码。
Sub command1_Click( )
Const N = 14
Dim a(1 to n) As Char, c As Char ‘数组a用于存储随机产生字母
Dim count, i, k, j as integer
Label1.caption = ""
For i = 0 To N
a(i) = ________
Label1.caption = a(i) & " "
Next i
For i = 0 To N - 1
k = i
For j = i + 1 To N
If a(j) > a(k) Then_________
Next j
c = a(i) : ___________: a(k) = c
Next i
For i = 0 To N '输出排序的结果
Label1.caption = a(i) & " "
Next i
i = 0
Do While i <= N '压缩显示相同元素
count = 1
If i < N Then j = i + 1
Do While a(i) = a(j)
If i <> j Then count = ____________
If j < N Then j = j + 1 Else Exit Do
Loop
If count = 1 Then
Label1.caption = a(i) & " "
Else
Label1.caption = ___________
End If
i = i + count
Loop
End Sub