急求vb程序代码!!!!
由输入对话框输入100个数值,数据放入数组a,其中的整数放入数组b,然后运用选择分类法将数组b中的数据按从大到小的顺序排列,并以每行五个数据在窗体上输出。...
由输入对话框输入100个数值,数据放入数组a,其中的整数放入数组b,然后运用选择分类法将数组b中的数据按从大到小的顺序排列,并以每行五个数据在窗体上输出。
展开
3个回答
展开全部
Private Sub Form_Click()
Cls
Dim a(100) As Single
Dim b(100) As Integer
'Randomize
j = 1
For i = 1 To 100
'a(i) = Int(Rnd() * 1000) / 10
a(i) = InputBox("", "")
If a(i) = Int(a(i)) Then
b(j) = a(i)
j = j + 1
End If
'Print a(i) & vbTab;
'If i Mod 10 = 0 Then Print
Next
For i = 1 To j - 2
For ii = i + 1 To j - 1
If b(i) < b(ii) Then
tt = b(i)
b(i) = b(ii)
b(ii) = tt
End If
Next
Next
Print
Print "结果"
For i = 1 To j - 1
Print b(i);
If i Mod 5 = 0 Then Print
Next
End Sub
Cls
Dim a(100) As Single
Dim b(100) As Integer
'Randomize
j = 1
For i = 1 To 100
'a(i) = Int(Rnd() * 1000) / 10
a(i) = InputBox("", "")
If a(i) = Int(a(i)) Then
b(j) = a(i)
j = j + 1
End If
'Print a(i) & vbTab;
'If i Mod 10 = 0 Then Print
Next
For i = 1 To j - 2
For ii = i + 1 To j - 1
If b(i) < b(ii) Then
tt = b(i)
b(i) = b(ii)
b(ii) = tt
End If
Next
Next
Print "结果"
For i = 1 To j - 1
Print b(i);
If i Mod 5 = 0 Then Print
Next
End Sub
展开全部
private sub command1_click()
dim a(1 to 100) as single,b() as integer,i,j
j=-1
for i=1 to 100
a(i)=val(inputbox("输入第" & i & "个数"))
if int(a(i))=a(i) then
j=j+1
redim preserver b(j)
b(j)=a(i)
next
for i=0 to j
for k=0 to i
if b(i)<b(k) then t=b(i):b(i)=b(k):b(k)=t
next
next
for i=0 to j
print b(i);
if (i+1) mod 5=0 then print
next
end sub
dim a(1 to 100) as single,b() as integer,i,j
j=-1
for i=1 to 100
a(i)=val(inputbox("输入第" & i & "个数"))
if int(a(i))=a(i) then
j=j+1
redim preserver b(j)
b(j)=a(i)
next
for i=0 to j
for k=0 to i
if b(i)<b(k) then t=b(i):b(i)=b(k):b(k)=t
next
next
for i=0 to j
print b(i);
if (i+1) mod 5=0 then print
next
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询