vb中将100到200中既能被3整除又能被5整除的数保存在数组中,并统计其个数

如题所述

第1个回答  2013-06-22
Private Sub Command1_Click()
Dim a(100), j, k As Integer
k = 1
For j = 100 To 200
If j Mod 3 = 0 And j Mod 5 = 0 Then
a(k) = j
k = k + 1
End If
Next j
Print k

End Sub本回答被网友采纳

用VB写代码产生10个100-200的随机数,保存在数组中,从小到大排序,输出...
Private Sub Form_Click() Dim a%(9), i%, j%, t% Randomize For i = 0 To UBound(a) a(i) = Int(Rnd * 101) + 100 Next For i = 0 To UBound(a) - 1 For j = 0 To UBound(a) - i - 1 If a(j) > a(j + 1) Then t = a(j):...

...产生100个1~100之间的整数,存放在一个一维数组中,显示所有最小的元素...
Private Sub Command1_Click() Cls Dim a(1 To 100) As Integer, min As Integer, n As Integer Randomize min = 100 Print "产生的随机数为:" For i = 1 To 100 a(i) = Int(Rnd * 100) + 1 Print Tab(5 * ((i - 1) Mod 10)); a(i); If ...

如何用VB的for循环编写产生10个100~200直接的数,求最大值
使用VB语言编写的程序,实现产生10个100~200的随机数,并求它们的最大值:```Dim num(9) As Integer '定义数组存储随机数Dim maxNum As Integer '定义变量存储最大值Randomize '初始化随机数种子For i = 0 To 9 '循环产生10个随机数num(i) = Int((200 - 100 + 1) * Rnd + 100) '...

怎么用vb设计 随机产生10个100到200之间的数,求出最大值与最小值_百 ...
1、首先需要启动VB6.0,新建一个标准exe工程。2、打开VB6.0之后,在窗体上绘制一个命令按钮。3、接下来需要双击命令按钮进入代码窗口。4、接下来开始编辑按钮的单击事件。5、最后就可以按F5运行测试。求出最大值与最小值。

...存放在一个数组中,然后求个元素和、平均值,统计
Randomize a(i) = Int(Rnd(1) * 101)x = x + a(i)Next i Print "元素和=" & x Print "平均值=" & x \/ 10 For i = 0 To 9 If a(i) > (x \/ 10) Then j = j + 1: y = y & CStr(a(i)) & " "Next i Print "大于平均值的元素个数=" & j Print "大于...

VB 求代码啊! 把20个整型数据存放到一维数组a中,找出a中出现频率最高的...
Private Sub Command1_Click()Dim a(19) As Double Dim b(19) As Double Dim c(19) As Boolean Dim t Dim maxx As Double For i = 0 To 19 t = InputBox("请输入第" & i + 1 & "个数:")Do While Not IsNumeric(t)t = InputBox("请输入第" & i + 1 & "个数:")Loo...

VB二维数组中找出相同值并统计个数
Const k = 13 Dim counts(), content()Sub aa()n = 0 ReDim Preserve content(1)content(1) = Cells(1, 1)For i = 1 To k For j = 1 To UBound(content)If Cells(i, 1) = content(j) Then m = m + 1 End If Next j If m = 0 Then n = UBound(content) + 1 Re...

vb程序设计:随机产生n个200~400个随机整数并存储在动态数组中。急急...
Private Sub Command1_Click()Dim n As Integer, a() As Integer, sum As Long, i, j, k As Integern = Val(InputBox("n="))ReDim a(1 To n)RandomizePrint "随机产生" & n & "个200~400的整数:"For i = 1 To n a(i) = Int(Rnd * 201) + 200 Print a(i); If...

...一维数组中,显示所有小于60的元素,并统计个数 vb函数 求解啊_百度...
Private Sub Command1_Click()Dim a(1 To 100) As Integer Cls For i = 1 To 100 Randomize a(i) = Int(Rnd * 100 + 1)If a(i) < 60 Then n = n + 1 Print a(i);If n Mod 10 = 0 Then Print End If Next i Print Print "小于60的元素共有"; n; "个"End Sub ...

用vb设计一个程序:从0到100中随机抽取10个数,保存到数组中,查找出最大...
l As Long, j As Long, n As Longh = 10Print "查找数据:"n = sz(0)For l = 0 To h - 1If n < sz(l) Thenn = sz(l)j = lEnd IfNext lPrint "最大数:" & n & "位置:" & j + 1End SubPrivate Sub Form_Load()Me.Caption = "李四"Command1.Caption = "生成"...

相似回答