如何用vb求3个数的平均数,几何平均数和平方平均数? 分开写,谢谢。(只要入门的程序就好,高级的不要)
展开全部
dim a as single
dim b as single
dim c as single
dim x as single
text1.text = a
text.2text = b
text3.text = c
label1.caption = x
(1)算术平均数:x = (a + b + c) / 3
(2)几何平均数:x = (a * b * c) ^ (1 / 3)
(3)平方平均数:x = [(a ^ 2 + b ^ 2 + c ^ 2)/3] ^ (1 / 3)
你上课肯定没听讲……
dim b as single
dim c as single
dim x as single
text1.text = a
text.2text = b
text3.text = c
label1.caption = x
(1)算术平均数:x = (a + b + c) / 3
(2)几何平均数:x = (a * b * c) ^ (1 / 3)
(3)平方平均数:x = [(a ^ 2 + b ^ 2 + c ^ 2)/3] ^ (1 / 3)
你上课肯定没听讲……
展开全部
dim a1,a2,a3,l,m,n
a1=1:a2=2:a3=3
l=(a1+a2+a3)/3 '平均数
print "平均数=";l
m=sqr(a1*a2*a3)
print "几何平均数=";m
n=sqr((a1^2+a2^2+a3^2)/3)
print "平方平均数=";n
a1=1:a2=2:a3=3
l=(a1+a2+a3)/3 '平均数
print "平均数=";l
m=sqr(a1*a2*a3)
print "几何平均数=";m
n=sqr((a1^2+a2^2+a3^2)/3)
print "平方平均数=";n
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim a, b, c
Dim jihe
Dim pingfang
a = Val(text1)
b = Val(text2)
c = Val(text3)
Private Sub Command1_Click()
jihe = (a + b + c) / 3
Print "这三个数的几何平均数为" & jihe
End Sub
Private Sub Command2_Click()
pingfang = Sqr((a ^ 2 + b ^ 2 + c ^ 2) / 3)
Print "这三个数的平方平均数为" & pingfang
End Sub
Dim jihe
Dim pingfang
a = Val(text1)
b = Val(text2)
c = Val(text3)
Private Sub Command1_Click()
jihe = (a + b + c) / 3
Print "这三个数的几何平均数为" & jihe
End Sub
Private Sub Command2_Click()
pingfang = Sqr((a ^ 2 + b ^ 2 + c ^ 2) / 3)
Print "这三个数的平方平均数为" & pingfang
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
' Function 一维数组求平均值,sigma '2007/9/18 备注: 前提的最大数值和最小值唯一,否则出错(比如:去一最大值和一最小值再求平均值会不准)
' CalAvg; Calculate data average and sigma
' argu ;
' Aa() : Data
' Avg : Data average
' Sig : Data sigma
' minData : high limit
' maxData : low limit
'==============================================================
Public Function CalAvg(AA() As Double, _
Avg As Double, _
Sig As Double, _
Optional minData As Double = 0, _
Optional maxData As Double = 0) As Double
Dim IntI As Long
Dim lngStart As Long
Dim lngEnd As Long
Dim Sum1 As Double
Dim Sum2 As Double
Dim Count As Double
Count = 0
Sum1 = 0
Sum2 = 0
lngStart = LBound(AA())
lngEnd = UBound(AA())
If maxData - minData = 0 Then
For IntI = lngStart To lngEnd
Count = Count + 1
Sum1 = Sum1 + AA(IntI)
Sum2 = Sum2 + AA(IntI) ^ 2
Next IntI
Else
For IntI = lngStart To lngEnd
If AA(IntI) > minData And AA(IntI) < maxData Then
Count = Count + 1
Sum1 = Sum1 + AA(IntI)
Sum2 = Sum2 + AA(IntI) ^ 2
End If
Next IntI
End If
If Count > 1 Then
Avg = Sum1 / Count
Sig = Sqr((Sum2 - Sum1 ^ 2 / Count) / (Count - 1))
ElseIf Count = 1 Then
Avg = Sum1
Sig = 0
Else
Avg = 0
Sig = 0
End If
CalAvg = Count
End Function
' CalAvg; Calculate data average and sigma
' argu ;
' Aa() : Data
' Avg : Data average
' Sig : Data sigma
' minData : high limit
' maxData : low limit
'==============================================================
Public Function CalAvg(AA() As Double, _
Avg As Double, _
Sig As Double, _
Optional minData As Double = 0, _
Optional maxData As Double = 0) As Double
Dim IntI As Long
Dim lngStart As Long
Dim lngEnd As Long
Dim Sum1 As Double
Dim Sum2 As Double
Dim Count As Double
Count = 0
Sum1 = 0
Sum2 = 0
lngStart = LBound(AA())
lngEnd = UBound(AA())
If maxData - minData = 0 Then
For IntI = lngStart To lngEnd
Count = Count + 1
Sum1 = Sum1 + AA(IntI)
Sum2 = Sum2 + AA(IntI) ^ 2
Next IntI
Else
For IntI = lngStart To lngEnd
If AA(IntI) > minData And AA(IntI) < maxData Then
Count = Count + 1
Sum1 = Sum1 + AA(IntI)
Sum2 = Sum2 + AA(IntI) ^ 2
End If
Next IntI
End If
If Count > 1 Then
Avg = Sum1 / Count
Sig = Sqr((Sum2 - Sum1 ^ 2 / Count) / (Count - 1))
ElseIf Count = 1 Then
Avg = Sum1
Sig = 0
Else
Avg = 0
Sig = 0
End If
CalAvg = Count
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
欢乐啊 又一个fc1的seminar
extra同学好像把计算和label.caption语句的顺序搞反了 btw平方平均数好像是开二次根号⋯⋯也可能不是 反正Ms陈嘉没讲 不过百度百科说开二次根号
extra同学好像把计算和label.caption语句的顺序搞反了 btw平方平均数好像是开二次根号⋯⋯也可能不是 反正Ms陈嘉没讲 不过百度百科说开二次根号
参考资料: 百度百科 obviously
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询