用VB生成100个随机数(范围为-1000到1000)并按升序排列,有木有大神会的啊?
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/12 23:30:42
用VB生成100个随机数(范围为-1000到1000)并按升序排列,有木有大神会的啊?
用VB随机生成100个随机数(范围为-1000到1000)并按升序排列,有木有大神会的啊?
用VB随机生成100个随机数(范围为-1000到1000)并按升序排列,有木有大神会的啊?
Private Sub Command1_Click()
Dim a(99) As Integer
Dim i As Integer, j As Integer, tmp As Integer
For i = 0 To 99
a(i) = Int(2001 * Rnd) - 1000
Next
For i = 0 To 99
For j = i To 99
If a(i) > a(j) Then
tmp = a(i)
a(i) = a(j)
a(j) = tmp
End If
Next
Next
End Sub
再问: 大神,我用text1显示刚生成的随机数,再用text2显示升序后的排列Command1是随机数生成按钮,Command2是升序排列按钮,我做出来后如下图但是运行时,提示我缺少数组。。。。现在应该怎么办啊?
再答: Private Sub Command1_Click() Dim a(99) As Integer Dim i As Integer, j As Integer, tmp As Integer For i = 0 To 99 a(i) = Int(2001 * Rnd) - 1000 Text1 = Text1 & a(i) & " " Next For i = 0 To 99 For j = i To 99 If a(i) > a(j) Then tmp = a(i) a(i) = a(j) a(j) = tmp End If Next Next For i = 0 To 99 Text2 = Text2 & a(i) & " " Next End Sub
再问: 大神,这是只用了Command1,那还要用Command2呢?Command1只显示生成的随机数,并不排列,Command2再排列,而且,我发现窗体不够啊,不能完全显示....如何让显示的数换行显示,让它显示完呢?多谢多谢
再答: Dim a(99) As Integer Private Sub Command1_Click() Dim i As Integer For i = 0 To 99 a(i) = Int(2001 * Rnd) - 1000 Text1 = Text1 & a(i) & " " Next End Sub Private Sub Command2_Click() Dim i As Integer, j As Integer, tmp As Integer For i = 0 To 99 For j = i To 99 If a(i) > a(j) Then tmp = a(i) a(i) = a(j) a(j) = tmp End If Next Next For i = 0 To 99 Text2 = Text2 & a(i) & " " Next End Sub 要换行,可以在text1和text2的属性里设置MultiLine属性为true
Dim a(99) As Integer
Dim i As Integer, j As Integer, tmp As Integer
For i = 0 To 99
a(i) = Int(2001 * Rnd) - 1000
Next
For i = 0 To 99
For j = i To 99
If a(i) > a(j) Then
tmp = a(i)
a(i) = a(j)
a(j) = tmp
End If
Next
Next
End Sub
再问: 大神,我用text1显示刚生成的随机数,再用text2显示升序后的排列Command1是随机数生成按钮,Command2是升序排列按钮,我做出来后如下图但是运行时,提示我缺少数组。。。。现在应该怎么办啊?
再答: Private Sub Command1_Click() Dim a(99) As Integer Dim i As Integer, j As Integer, tmp As Integer For i = 0 To 99 a(i) = Int(2001 * Rnd) - 1000 Text1 = Text1 & a(i) & " " Next For i = 0 To 99 For j = i To 99 If a(i) > a(j) Then tmp = a(i) a(i) = a(j) a(j) = tmp End If Next Next For i = 0 To 99 Text2 = Text2 & a(i) & " " Next End Sub
再问: 大神,这是只用了Command1,那还要用Command2呢?Command1只显示生成的随机数,并不排列,Command2再排列,而且,我发现窗体不够啊,不能完全显示....如何让显示的数换行显示,让它显示完呢?多谢多谢
再答: Dim a(99) As Integer Private Sub Command1_Click() Dim i As Integer For i = 0 To 99 a(i) = Int(2001 * Rnd) - 1000 Text1 = Text1 & a(i) & " " Next End Sub Private Sub Command2_Click() Dim i As Integer, j As Integer, tmp As Integer For i = 0 To 99 For j = i To 99 If a(i) > a(j) Then tmp = a(i) a(i) = a(j) a(j) = tmp End If Next Next For i = 0 To 99 Text2 = Text2 & a(i) & " " Next End Sub 要换行,可以在text1和text2的属性里设置MultiLine属性为true
用VB如何从0到33中选出6个随机数并按升序排列
vb语句 设计一个随机数程序,生成10个范围是1到100随机整数,并求出这10个数的最大值,最小值和平均数
用vb怎样生成10个不重复的(1到10)随机数?
随机产生300个1000以内的正整数,求出素数个数找出其中素数并按升序排列
VB:产生20个30到50之间的随机数,并以每行4个进行排列.要求代码尽可能简洁易懂,
怎么用VB编写点生成按钮产生1000个8位不重复的随机数呢?
用vb如何生成0-100之间的随机数
vb利用随机函数产生50到100范围的30个随机数,显示其中最大值,最小值,平均值,
用JAVA编写一个程序,要求生成5个随机数,随机数的取值范围是20到60
用vb生成6个两位数的随机数,求得平均值,显示生成的两位数和平均值
VB怎么写随机生成10个[1,100]之间的数,并从大到小排列的程序?
vb 生成随机数(急!)