1.
给定12个不同的正整数,任务是计算这些数里面有多少个数对满足:数对中一个数是另一个数的两倍。比如给定8 13 21 28 19 33 10 17 42 5 38 7,得到的答案是3,因为10是5的两倍,42是21的两倍,38是19的两倍。下列VB代码段能实现上述功能,请将划线处代码补充完整:
Private Sub Command2_Click()
Const n=12
Dim a(1 To n) As Integer, s As
Integer
Dim i As Integer, j As Integer
Randomize
For i=1 To n
a(i)=Int(Rnd * 50)+1
For j=1 To i- 1
If a(i)=a(j) Then
Next j
If j <i
Then
Next i
For i=1 To n
For j=1 To n
If Then
s=s+1
List1. AddItem
Str(s)+":"+
Str(a(i)) + Str(a(j))
Exit For跳出内层循环
End If
Next j
Next i
End Sub