随机生成100内的10个整数_VB随机生成100个两位整数,并统计出其中小于等于40

  • Post author:
  • Post category:其他


随机生成100个两位整数,并统计出其中小于等于40、大于40且小于等于70及大于70的数据个数。

解,此题VB代码如下:

Option Base 1

Private Sub Form_Click()

Dim a(100) As Integer, i As Integer, m As Integer, n As Integer, k As Integer

Cls’先清屏

Print “生成100个两位随机整数”

For i = 1 To 100

a(i) = Int(Rnd * 90) + 10

Print a(i);

If i Mod 10 = 0 Then Print ‘一行只输出10个

m = 0: n = 0: k = 0

For i = 1 To 100

If a(i) <= 40 Then

m = m + 1

ElseIf a(i) > 40 And a(i) <= 70 Then

n = n + 1

Else

k

Print “统计情况:”

Print “小于等于40的数有”; m

Print “小于等于70的数有”; n

Print “大于70的数有”; k

End Sub

于等于70的数有”; n

Print “大于70的数有”; k

End Sub

运行程序,点击窗体,此题程序运行效果图如下:

4bda388af54a7cb53fbbaa2604921202.png



版权声明:本文为weixin_34898320原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。