用VB编程:随机产生10个0~100之间的随机整数,存放在一个数组中,然后求

如题所述

private
sub
command3_click()
'用vb编程:随机产生10个0~100之间的随机整数,存放在一个数组中,
'然后求个元素和、平均值,统计
'大于平均值的元素个数并把它们显示出来?
dim
myvalue(100)
as
integer
dim
i
as
integer
dim
n
as
integer
dim
sum
as
double
dim
ave
as
double
n
=
100
sum
=
0
ave
=
0
for
i
=
1
to
n
myvalue(i)
=
int(100
*
rnd)
'
生成
0

6
之间的随机数值。
sum
=
sum
+
myvalue(i)
next
i
ave
=
sum
/
n
for
i
=
1
to
n
if
myvalue(i)
>
ave
then
print
myvalue(i)
end
if
next
i
end
sub
温馨提示:内容为网友见解,仅供参考
无其他回答

用VB编程:随机产生10个0~100之间的随机整数,存放在一个数组中,然后求个...
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编程题目: 随机产生10个0-100之间的整数放入数组,显示数组各元素的值...
Print "最小值:"; min Print "平均值:"; sum \/ 10 End Sub

vb编程:随机产生10个0~100之间的数放到一个一维数组中,将10个数从小...
Private Sub Form_Load()Dim arr(1 To 10), i, j, tmp Me.AutoRedraw = True Randomize For i = 1 To 10 arr(i) = Int(Rnd * 101)Print arr(i);Next i Print For i = 1 To 10 For j = i + 1 To 10 If arr(i) > arr(j) Then tmp = arr(i)arr(i) = arr(j)arr...

用vb设计一个程序:从0到100中随机抽取10个数,保存到数组中,查找出最大...
msgbox "数组元素有:" & vbcrlf & s & "最大值是:" & a(j) & " 位于第" & j+1 & "个"''说明:这里最后给出的数组元素位置,是按照生活习惯从1开始计数的,所以用了 j+1,''如果是按照VB规则从0计数,最后这里,直接用j就可以了。

计算机VB中,利用随机函数产生10个10-100的随机数,并将其赋值给数组a...
Private Sub Command1_Click() Dim a(10) As Integer Randomize For i = 1 To 10 a(i) = Int(Rnd() * 91) + 10 Print a(i); s = s + a(i) Next i Print Print "平均值="; s \/ 10End Sub

关于VB:随机产生10个 递增的 100到400的随机数,存放到数组中,并显示结...
Private Sub Form_Click()Cls Randomize Dim a(0 To 9)Print "随机生成的10个数字为:"For i = 0 To 9 a(i) = Int(Rnd * 301 + 100)Print a(i) & " ";Next For i = 9 To 1 Step -1 For j = 0 To i - 1 If a(j) > a(j + 1) Then t = a(j)a(j) = a(j...

用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 = "生成"...

用VB编写一个程序:随机产生10个递增的100~400的随机数,存放到数组中...
private sub FORM1_LOAD()dim a(1 to 10) as Integer,I AS INTEGER FOR I=1 TO 10 A(I)=RAND*300+100 NEXT 对数组排序,课本上有的,抄过来就可以,我就不往上敲了 END SUB 如果不行就是你窗体的属性设置不对,具体我忘那个属性了,你做一个按钮,把时间改为单击按钮事件 ...

vb随机产生10个整数,范围在[0,100]之间,放在数组A中,按递增序列排序
Private Sub Command1_Click()Dim i As Integer, j As Integer, exchange As Integer, a(9) As Integer For i = 0 To 9 Randomize a(i) = Rnd * (101)Next i For i = 1 To 9 For j = 0 To 9 - i If a(j) > a(j + 1) Then exchange = a(j)a(j) = a(j + 1)...

...要编写一个VB程序,点击command1时,随机产生10个0到100的随机整数...
Option Base 1 Private Sub command1_click()Dim a(10) As Integer Dim temp As Long For i = 1 To 10 a(i) = Int(Rnd * 100 + 0.5)Next i Text1.Text = a(1) & Space(2) & a(2) & Space(2) & a(3) & Space(2) & a(4) & Space(2) & a(5) & Space(2) ...

相似回答