早教吧作业答案频道 -->其他-->
Dima(1To5)AsIntegerPrivateSubCommand1Click()Dimi%,k%,t%,x%Fori=1To5a(i)=Int(Rnd*20)Picture1.Printa(i);Space(2);NextiFork=LBound(a())ToUBound(a())Fort=kTo(UBound(a())-1)Ifa(k)>a(t+1)Thenz=a(t+1)a(t+1)=a(k
题目详情
Dim a(1 To 5) As Integer
Private Sub Command1_Click()
Dim i%,k%,t%,x%
For i = 1 To 5
a(i) = Int(Rnd * 20)
Picture1.Print a(i); Space(2);
Next i
For k = LBound(a()) To UBound(a())
For t = k To (UBound(a()) - 1)
If a(k) > a(t + 1) Then
z = a(t + 1)
a(t + 1) = a(k)
a(k) = z
End If
Next t
Next k
For i = 1 To 5
Picture2.Print a(i); Space(2);
Next i
End Sub
Private Sub Command1_Click()
Dim i%,k%,t%,x%
For i = 1 To 5
a(i) = Int(Rnd * 20)
Picture1.Print a(i); Space(2);
Next i
For k = LBound(a()) To UBound(a())
For t = k To (UBound(a()) - 1)
If a(k) > a(t + 1) Then
z = a(t + 1)
a(t + 1) = a(k)
a(k) = z
End If
Next t
Next k
For i = 1 To 5
Picture2.Print a(i); Space(2);
Next i
End Sub
▼优质解答
答案和解析
Dim a(1 To 5) As Integer //定义名为a的五元素数组,
Private Sub Command1_Click() //鼠标点击动作
Dim i%, k%, t%, x% //定义四个整形变量
For i = 1 To 5 //for循环
a(i) = Int(Rnd * 20) //给数组a的五个元素赋值,为0-20的随机数
Picture1.Print a(i); Space(2); //在Picture1控件上输出数组a的五个值
Next i //同上
For k = LBound(a()) To UBound(a()) //k从a的下界到上限的for循环
For t = k To (UBound(a()) - 1) //for嵌套t从当前k值到a上限减1
If a(k) > a(t + 1) Then
z = a(t + 1)
a(t + 1) = a(k)
a(k) = z
End If //对数组a的元素进行排序
Next t
Next k
For i = 1 To 5
Picture2.Print a(i); Space(2);//将排序后的结果在控件Picture2中输出
Next i
End Sub//结束
总而言之,就是定义一个数组->赋值->第一次输出->排序->第二次输出 这样一个程序
Private Sub Command1_Click() //鼠标点击动作
Dim i%, k%, t%, x% //定义四个整形变量
For i = 1 To 5 //for循环
a(i) = Int(Rnd * 20) //给数组a的五个元素赋值,为0-20的随机数
Picture1.Print a(i); Space(2); //在Picture1控件上输出数组a的五个值
Next i //同上
For k = LBound(a()) To UBound(a()) //k从a的下界到上限的for循环
For t = k To (UBound(a()) - 1) //for嵌套t从当前k值到a上限减1
If a(k) > a(t + 1) Then
z = a(t + 1)
a(t + 1) = a(k)
a(k) = z
End If //对数组a的元素进行排序
Next t
Next k
For i = 1 To 5
Picture2.Print a(i); Space(2);//将排序后的结果在控件Picture2中输出
Next i
End Sub//结束
总而言之,就是定义一个数组->赋值->第一次输出->排序->第二次输出 这样一个程序
看了Dima(1To5)AsInt...的网友还看了以下:
产生[1,50]范围内某一随机整数的表达式是()A.Rnd*50B.Int(Rnd*50)C.In 2020-05-14 …
你帮我看看这句话有错么Dim ,,Form2.Picture1.Scale (-10,3)-(30 2020-05-16 …
49B0C不确定D程序出错选哪个呢?为什么?VB程序Dimaa=Array(1,2,3,4,5,6 2020-07-09 …
3、下列程序代码有几处错误,请指出;(20分)Dimx,ySinglePicture1.Scale 2020-07-19 …
Dima(1To5)AsIntegerPrivateSubCommand1Click()Dimi%, 2020-11-01 …
一个非常简单的VB问题:PrivateSubTimer1Timer()'右壁弹回IfShape1.L 2020-11-01 …
1道VB题目说明理由1.可以产生30-50(含30和50)之间的随机整数的表达式是A.Int(Rnd 2020-11-01 …
RandomizeFori=1To5Forj=1To5-1a(i,j)=Int(40*Rnd)*2+ 2020-11-01 …
在VB中,产生10到50之间(包括10和50)随机证书的表达式是。在VB中,产生10到50之间(包括 2020-12-26 …
VB语句中LBound()ToUBound()VB中这样一句是什么意思?Fori=LBound(in 2021-02-05 …