vb编程:随机产生10个1–100之间的整数,并按从小到大顺序输出,谁能帮我编一下
答案:2 悬赏:20 手机版
解决时间 2021-02-11 12:30
- 提问者网友:暗中人
- 2021-02-10 15:39
vb编程:随机产生10个1–100之间的整数,并按从小到大顺序输出,谁能帮我编一下
最佳答案
- 五星知识达人网友:天凉才是好个秋
- 2021-02-10 16:43
Private Sub Command1_Click()
Dim a(10), i, j As Integer
For i = 0 To 9
a(i) = Int(Rnd * 100) + 1
Print a(i);
Next
For i = 0 To 8
For j = i To 9
If a(i) > a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next
Next
Print
For i = 0 To 9
Print a(i)
Next
End Sub
Dim a(10), i, j As Integer
For i = 0 To 9
a(i) = Int(Rnd * 100) + 1
Print a(i);
Next
For i = 0 To 8
For j = i To 9
If a(i) > a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next
Next
For i = 0 To 9
Print a(i)
Next
End Sub
全部回答
- 1楼网友:空山清雨
- 2021-02-10 18:03
abc,dat改为abc.dat,a(i) = int(rnd * 10)改为a(i) = int(rnd * 11)(否则只能产生0-9的随机数)
write #10, a(10)改为write #1, a(i),正确的代码如下:
private sub command1_click()
dim a(10) as integer, i%
open "abc.dat" for output as #1
for i = 1 to 10
a(i) = int(rnd * 11)
write #1, a(i)
next i
close #1
end sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯