请教一道VB题(编写子过程好头晕)
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/06 08:12:48
请教一道VB题(编写子过程好头晕)
3、 过键盘输入10个整数,输出其中的最大数和平均数,并将这10个数从小到大排序输出到窗体上.要求分别编写子过程max,aven,sort 来求最大数、平均数、和排序,在窗体的单击事件过程中调用这些函数.
3、 过键盘输入10个整数,输出其中的最大数和平均数,并将这10个数从小到大排序输出到窗体上.要求分别编写子过程max,aven,sort 来求最大数、平均数、和排序,在窗体的单击事件过程中调用这些函数.
Option Explicit
Private Sub Form_Click()
Dim d(1 To 10) As Integer
Dim i As Integer
Dim MyMax As Integer
Dim MyAve As Single
'输入
For i = 1 To 10
d(i) = Val(InputBox("请输入第 " & CStr(i) & " 个数!"))
Next i
'调用求最大值的过程
Call Max(d,MyMax)
'输出
Print "最大值:" & MyMax
Print
'调用求平均值的过程
Call aven(d,MyAve)
'输出
Print "平均值:" & MyAve
Print
'调用排序(升序)过程
Call sort(d)
'输出
For i = 1 To 10
Print d(i); " ";
Next i
End Sub
Private Sub Max(ByRef d() As Integer,ByRef Max As Integer)
Dim i As Integer
Max = d(1)
For i = 2 To 10
If d(i) > Max Then Max = d(i)
Next i
End Sub
Private Sub aven(ByRef d() As Integer,ByRef AVE As Single)
Dim TT As Integer
Dim i As Integer
TT = 0
For i = 1 To 10
TT = TT + d(i)
Next i
AVE = TT / 10
End Sub
Private Sub sort(ByRef d() As Integer)
Dim i As Integer
Dim j As Integer
Dim T As Integer
'排序
For i = 1 To 9
For j = i + 1 To 10
If d(i) > d(j) Then
T = d(i)
d(i) = d(j)
d(j) = T
End If
Next j
Next i
End Su
Private Sub Form_Click()
Dim d(1 To 10) As Integer
Dim i As Integer
Dim MyMax As Integer
Dim MyAve As Single
'输入
For i = 1 To 10
d(i) = Val(InputBox("请输入第 " & CStr(i) & " 个数!"))
Next i
'调用求最大值的过程
Call Max(d,MyMax)
'输出
Print "最大值:" & MyMax
'调用求平均值的过程
Call aven(d,MyAve)
'输出
Print "平均值:" & MyAve
'调用排序(升序)过程
Call sort(d)
'输出
For i = 1 To 10
Print d(i); " ";
Next i
End Sub
Private Sub Max(ByRef d() As Integer,ByRef Max As Integer)
Dim i As Integer
Max = d(1)
For i = 2 To 10
If d(i) > Max Then Max = d(i)
Next i
End Sub
Private Sub aven(ByRef d() As Integer,ByRef AVE As Single)
Dim TT As Integer
Dim i As Integer
TT = 0
For i = 1 To 10
TT = TT + d(i)
Next i
AVE = TT / 10
End Sub
Private Sub sort(ByRef d() As Integer)
Dim i As Integer
Dim j As Integer
Dim T As Integer
'排序
For i = 1 To 9
For j = i + 1 To 10
If d(i) > d(j) Then
T = d(i)
d(i) = d(j)
d(j) = T
End If
Next j
Next i
End Su
请教一道VB题(编写子过程好头晕)
vb分别用子过程和子函数编写求两个数的最大公约数(算法用辗转相减法)
VB中编写一个子过程,计算1*3+2*4+3*5+····+(n-2)*n的值
请教一道函数求值域题(要解题过程)
请教一道填空题的过程.
VB编写计算圆面积的Function过程.
vb中编写过程,计算π的近似值
vb编写判断奇,偶数的函数过程.
用VB编写一程序,产生20个0~100的随机数,并用子过程的方法按从大到小的顺序排列显示
编写一个计算个人所得税的程序(用VB编写)
一道VB运算题not (3〉4)and not 5 or 1 麻烦给出过程和结果,
请教一道初中几何题(原题无图),要求给出完整解答过程.