展开全部
Private Sub Form_Click()
Form1.Cls
Dim A(10) As Integer
Dim B(10) As Boolean
Dim I As Integer, J As Integer
Dim K As Integer
Randomize
Form1.AutoRedraw = True
For I = 1 To 10
A(I) = Int(Rnd * 10)
Print A(I);
B(I) = True
Next
Print
For I = 1 To 10
If B(I) Then
Print A(I); ":"; I;
B(I) = False
For J = 1 To 10
If B(J) Then
If A(I) = A(J) Then
Print J;
B(J) = False
End If
End If
Next
Print
End If
Next
End Sub
Form1.Cls
Dim A(10) As Integer
Dim B(10) As Boolean
Dim I As Integer, J As Integer
Dim K As Integer
Randomize
Form1.AutoRedraw = True
For I = 1 To 10
A(I) = Int(Rnd * 10)
Print A(I);
B(I) = True
Next
For I = 1 To 10
If B(I) Then
Print A(I); ":"; I;
B(I) = False
For J = 1 To 10
If B(J) Then
If A(I) = A(J) Then
Print J;
B(J) = False
End If
End If
Next
End If
Next
End Sub
追问
看不太懂,能不能说明下
追答
Private Sub Form_Click()
Form1.Cls‘清屏
Dim A(10) As Integer‘声明变量
Dim B(10) As Boolean
Dim I As Integer, J As Integer
Dim K As Integer
Randomize’随机数种子
Form1.AutoRedraw = True‘自动刷新
For I = 1 To 10
A(I) = Int(Rnd * 10)’赋值
Print A(I);‘打印
B(I) = True’记录是否有相同值
Next
For I = 1 To 10‘以下查询相同的元素并打印
If B(I) Then
Print A(I); ":"; I;
B(I) = False
For J = 1 To 10
If B(J) Then
If A(I) = A(J) Then
Print J;
B(J) = False
End If
End If
Next
End If
Next
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询