Dim i1 As Single
Dim wendu_i1(1 To 10) As Single
现在想将 这十个wendu_i1去掉一个最大值 去掉一个最小值 然后把剩下来的8个数的平均值赋给i1
要怎么编程 谢啦
VB中 求平均值
答案:4 悬赏:10 手机版
解决时间 2021-02-01 15:25
- 提问者网友:沉默的哀伤
- 2021-02-01 12:31
最佳答案
- 五星知识达人网友:行雁书
- 2021-02-01 13:46
假设wendu_i1数组已赋值了(至于怎么赋值自行解决)
for i=3 to 10
if wendu_i1(1)<wendu_i1(i) then
i1 =wendu_i1(1)
wendu_i1(1)=wendu_i1(i)
wendu_i1(i)=i1
end if
if wendu_i1(2)>wendu_i1(i) then
i1 =wendu_i1(2)
wendu_i1(2)=wendu_i1(i)
wendu_i1(i)=i1
end if
next
这样后wendu_i1(1)是最大值 ,wendu_i1(2)是最小值
i1=0
for i=3 to 10
i1=i1+wendu_i1(i)
next
i1=i1/8
print i1
for i=3 to 10
if wendu_i1(1)<wendu_i1(i) then
i1 =wendu_i1(1)
wendu_i1(1)=wendu_i1(i)
wendu_i1(i)=i1
end if
if wendu_i1(2)>wendu_i1(i) then
i1 =wendu_i1(2)
wendu_i1(2)=wendu_i1(i)
wendu_i1(i)=i1
end if
next
这样后wendu_i1(1)是最大值 ,wendu_i1(2)是最小值
i1=0
for i=3 to 10
i1=i1+wendu_i1(i)
next
i1=i1/8
print i1
全部回答
- 1楼网友:老鼠爱大米
- 2021-02-01 15:31
Private Sub Command1_Click()
Dim i1 As Single
Dim wendu_i1(1 To 10) As Single
Dim i As Integer, max As Single, min As Integer, m As Integer, n As Integer
max = wendu_i1(1)
min = wendu_i1(10)
For i = 1 To 10
If max < wendu_i1(i) Then max = wendu_i1(i): m = i
If min > wendu_i1(i) Then min = wendu_i1(i): n = i
Next
wendu_i1(m) = wendu_i1(1): wendu_i1(1) = max
wendu_i1(n) = wendu_i1(10): wendu_i1(10) = min
For i = 2 To 9
i1 = i1 + wendu_i1(i)
Next
i1 = i1 / 8
End Sub
- 2楼网友:走死在岁月里
- 2021-02-01 15:24
dim max,min as single
min=wendu_i1(1)
for a=1 to 10
if wendu_i1(a)>max then max=wendu_i1(a)
if wendu_il(a)<min then min=wendu_i1(a)
i1=i1+wendu_i1(a)
next
i1=(i1-min-max)/8
print i1
- 3楼网友:醉吻情书
- 2021-02-01 14:07
dim a(1 to 7) as integer
private sub command1_click() text1.text = "" randomize for i = 1 to 7 a(i) = int(rnd() * 90 + 10) text1.text = text1.text + str(a(i)) + " " next i end sub
private sub command2_click() dim s as integer for i = 1 to 7 s = s + a(i) next i text2.text = s / 7 end sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯