vb题:输入20个任意数放入数组a,把其中的整数放入数组b,排序后将所有整数输出。
答案:4 悬赏:10 手机版
解决时间 2021-04-13 04:19
- 提问者网友:嘚啵嘚啵
- 2021-04-12 18:06
vb题:输入20个任意数放入数组a,把其中的整数放入数组b,排序后将所有整数输出。
最佳答案
- 五星知识达人网友:夜余生
- 2021-04-12 18:23
Private Sub Command1_Click()
Cls
Randomize (Timer)
Dim a(19) As Single, b() As Long
For i = 0 To 19
a(i) = Rnd * 10000000
Print a(i);
If (i + 1) Mod 10 = 0 Then Print
If Int(a(i)) = a(i) Then
ReDim Preserve b(k)
b(k) = a(i)
k = k + 1
End If
Next i
Print
For i = LBound(b) To UBound(b) - 1
For j = i + 1 To UBound(b)
If b(j) < b(i) Then
t = b(i)
b(i) = b(j)
b(j) = t
End If
Next j
Next i
For i = LBound(b) To UBound(b)
Print b(i);
If (i + 1) Mod 10 = 0 Then Print
Next i
End Sub
Cls
Randomize (Timer)
Dim a(19) As Single, b() As Long
For i = 0 To 19
a(i) = Rnd * 10000000
Print a(i);
If (i + 1) Mod 10 = 0 Then Print
If Int(a(i)) = a(i) Then
ReDim Preserve b(k)
b(k) = a(i)
k = k + 1
End If
Next i
For i = LBound(b) To UBound(b) - 1
For j = i + 1 To UBound(b)
If b(j) < b(i) Then
t = b(i)
b(i) = b(j)
b(j) = t
End If
Next j
Next i
For i = LBound(b) To UBound(b)
Print b(i);
If (i + 1) Mod 10 = 0 Then Print
Next i
End Sub
全部回答
- 1楼网友:詩光轨車
- 2021-04-12 20:05
这你都不会写?你学过VB吗?
- 2楼网友:一叶十三刺
- 2021-04-12 19:49
C语言中数组都是有类型定义的,不存在“任意数”吧。
- 3楼网友:罪歌
- 2021-04-12 19:04
容易
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯