袜子颜色配对问题。现有不同颜色的袜子若干(袜子的颜色用数字编号1~15表示),颜色相同的袜子才能组成一双,其中有几只袜子是落单的,现要求找出落单袜子的颜色以及能够配对的袜子数量。编写程序解决该问题,程序运行时,在文本框Text1中依次输入袜子的颜色编号(数据都用逗号分隔并以逗号结尾),单击“查找”按钮,在列表框List1中输出落单袜子的颜色编号,在标签label1中现实能配对的袜子数量。运行界面如图所示,实现上述功能的VB程序如下。
Const n = 15
Private Sub Command1_Click()
Dim a(1 To n) As Integer '数组a存放不同颜色袜子的数量,默认值为0
Dim s As String, ch As String
Dim c As Integer, i As Integer, t As Integer
List1.Clear
s = Text1.Text
t = 0 :c = 0 : i = 1
Do While i <= Len(s)
ch = Mid(s, i, 1)
If ch >= "0" And ch <= "9" Then
t = t * 10 + Val(ch)
Else
a(t) = ①
t = 0
End If
i = i + 1
Loop
For i = 1 To n
If ② Then List1.AddItem "落单袜子的颜色为" + Str(i)
c =
Next i
Label1.Caption = "能配对的袜子有" + Str(c) + "双"
End Sub
请回答下列问题: