vb编程,用随机函数产生50个10~100之间的互不相同的整数存于一数组中,并以升序每行10个数显示在窗体上

 我来答
百度网友bdb9803
2012-03-22 · TA获得超过1.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:53%
帮助的人:1亿
展开全部
Private Sub Command1_Click()
Dim x(90) As Integer

'高效代码,产生无重复随机数
For i = 10 To 100
x(i - 10) = i
Next
Randomize
For i = 1 To 50
j = Int(Rnd * (91 - i)) + i
t = x(i)
x(i) = x(j)
x(j) = t
Next

'排序
For i = 1 To 50
For j = 1 To i
If x(i) < x(j) Then t = x(i): x(i) = x(j): x(j) = t
Next
Next

'显示
For i = 1 To 50
Print x(i);
If i Mod 10 = 0 Then Print
Next
End Sub
百度网友ffe7f1a
推荐于2017-05-23 · TA获得超过205个赞
知道小有建树答主
回答量:617
采纳率:0%
帮助的人:442万
展开全部
Private Sub Command1_Click()
Dim NumA(50) As Integer, Tmp1 As Long, Tmp2 As Long
For Tmp1 = 1 To 50
NumA(Tmp1) = Rnd() * 90 + 10
Next
NumA(0) = NumA(1)
For Tmp1 = 1 To 49
For Tmp2 = Tmp1 To 50
If NumA(Tmp2) < NumA(Tmp1) Then
NumA(0) = NumA(Tmp2)
NumA(Tmp2) = NumA(Tmp1)
NumA(Tmp1) = NumA(0)
End If
Next
If Tmp1 Mod 10 = 0 Then
Print NumA(Tmp1)
Else
Print NumA(Tmp1);
End If
Next
Print NumA(50)
End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式