VB排序,分别去掉最大最小值,然后其余数求平均值
'16个文本框组成控件数组
Private Sub Command1_Click()
Dim a(15)
For i = 0 To 15
a(i) = Val(Text1(i).Text)
Next
For i = 0 To 15
For j = 0 To i
If a(i) < a(j) Then t = a(i): a(i) = a(j): a(j) = t
Next
Next
For i = 3 To 12
s = s + a(i)
Next
MsgBox "平均值=" & s / 10
End Sub
添加一个Command1,10个text,分别为text1(0),text1(1).....text1(9),用来输入10个评委的分数,1个text2输出结果。
Private Sub Command1_Click()
Dim MaxT, MinT, SumT As Long
MaxT = Text1(0).Text
MinT = Text1(0).Text
SumT = 0
For i = 0 To 9
SumT = SumT + Text1(i).Text '求和
If Text1(i).Text >= MaxT Then
MaxT = Text1(i).Text '最大值
End If
If Text1(i).Text <= MaxT Then
MinT = Text1(i).Text '最小值
End If
Next
Text2.Text = Format((SumT - MaxT - MinT) / 8, "0.00") '计算平均值
End Sub
'示例: (假设要对长整型数组Arr排序并求去头尾后的平均值)
'MsgBox GetAverage(Arr)
Private Function GetAverage(Source() As Long)
InsertSort Source
Dim i As Long, Sum As Long
For i = LBound(Source) + 1 To UBound(Source) - 1
Sum = Sum + Source(i)
Next
If UBound(Source) - LBound(Source) - 2 > 0 Then GetAverage = Sum / (UBound(Source) - LBound(Source) - 2)
End Function
Private Sub InsertSort(Source() As Long)
Dim i As Long, j As Long, k As Long, c As Long
ReDim n(LBound(Source) To UBound(Source)) As Long
c = LBound(Source)
For i = LBound(Source) To UBound(Source)
For j = LBound(Source) To c - 1
If Source(i) <= n(j) Then Exit For
Next
For k = c - 1 To j Step -1
n(k + 1) = n(k)
Next
n(j) = Source(i)
c = c + 1
Next
For i = LBound(Source) To UBound(Source)
Source(i) = n(i)
Next
End Sub
C语言 N名选手,M个评委,去掉最高分和最低分求每个选手的平均分,并排...
float sum,b[100];int i,j,k,t;scanf("%d %d",&n,&m);\/\/m个人给n个人打分 for(i=0;i<n;i++){ for(j=0;j<m;j++){ scanf("%d",&a[i][j]);\/\/所打的分数 } } for(i=0;i<n;i++){ k=0;t=0;for(j=1;j<m;j++){ if(a[j]>a[k])k=j;\/\/去掉最低分 ...
C语言编程:十个评委分别为十位歌手评分,去掉一个最高分,去掉一个最低...
include <stdio.h>#include <stdlib.h>#define NUM10int findMax(int *buf){int index = 0, max = buf[0];for (int i=1; i < NUM; i++){if (buf[i] > max){index = i;}}return index;}int findMin(int *buf){int index = 0, min = buf[0];for (int i=1; i < ...
在EXCEL排序中为什么带字母总是排最底下?我想放在与前面几个数值相同的...
这是文本和数字混合的排序,用一般方法难以达到你的效果,需要用自定义函数来实现
EXCEL中20名评委给70名选手打分,去掉五个最高分,五个最低分,再求平均...
将统分表设计成如图,在W2单元格输入公式 =TRIMMEAN(C2:V2,0.5)(这公式会去掉每个选手得分中五个最高分,五个最低分,然后求出平均值)在X2单元格输入公式=RANK(W2,$W$2:$W$71)然后将W2:X2复制粘贴到下页各行。
...选手打分,分数为1-100分,选手最后得分为去掉一个最高分
代码如下 include <iostream> using namespace std;int main(){int a[10],f[10],i,k,m,n,b,c,y,p,q,d,average,h,g;cout<<"输入十位评委按顺序的打分:";for(i=0;i<10;i++){cin>>a[i];} for(b=0;b<10;b++){while(a[b]>100||a[b]<0){cout<<"选手得分超出规定...
归并排序
归并排序(Merge Sort)将会用到上面所说的合并操作。给出一个数列,归并排序利用合并操作在O(nlogn)的时间内将数列从小到大排序。归并排序用的是分治(Divide and Conquer)的思想。首先我们把给出的数列平分为左右两段,然后对两段数列分别进行排序,最后用刚才的合并算法把这两段(已经排过序的)数列合并为一个数列...
...200梯形图,要求一个采样周期采样十个数据,去掉最大和最小值,剩余...
求平均值可以通过指针,也可以直接地址运算。(前提是你的数据放在某一个固定区域)2、通过指针运算。存储数据通过指针变址存储,可针对不同数据类型,比如B,WORD,DINT,REAL,然后再通过上面说的排序,去除最大值,最小值,求中间的平均值。(排序和求平均值参考上面描述)原来设计这个程序的目的是为了...
EXCEL 排序问题 求大神提点!
假设这列数在A列。在B2输入:=LEFT(A2,4)&"-"&CHAR(64+MID(A2,FIND("-",A2)+1,FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1))&"-"&RIGHT(A2)然后根据b列升序排序就好了
如何让B列数值随着A列数值自动排序?
1、打开excel表格,在A列与B列中分别输入需要排序的数据。2、要实现B列随着A列的排序一起变动,需要同时选中两列单元格。3、点击表格上方的工具栏中的“数据”,选择“排序”按钮。4、在弹出的“排序”对话框中,将“主要关键字”选择为“列A”,排序依据为“数值”。5、点击确定后,表格完成排序...
excel或word中如何把含有指定字符数量超过指定值的行删除
假设这是a列 在b1单元格输入 =if(len(a1)-len(substitue(a1,"b",""))>5,"删除","")下拉 b列选择性粘贴为数值后,按b列排序,显示删除的去掉
景雄鼻炎: '添加如下两个过程,然后调用 GetAverage 即可.'示例: (假设要对长整型数组Arr排序并求去头尾后的平均值)'MsgBox GetAverage(Arr) Private Function GetAverage(Source() As Long) InsertSort Source Dim i As Long, Sum As Long For i = ...
郾城县15320301034: 如何在vb中,16个文本框中输入16个数字,然后去掉3个最小值,去掉3个最大值后,求平均值??谢谢 - ?
景雄鼻炎: '16个文本框组成控件数组 Private Sub Command1_Click() Dim a(15) For i = 0 To 15 a(i) = Val(Text1(i).Text) Next For i = 0 To 15 For j = 0 To i If a(i) < a(j) Then t = a(i): a(i) = a(j): a(j) = t Next Next For i = 3 To 12 s = s + a(i) Next MsgBox "平均值=" & s / 10 End Sub
郾城县15320301034: VB输入10个数字,去掉其最大数和最小数,求平均数 - ?
景雄鼻炎: Private Sub Command1_Click() Dim i As Integer Dim j As Integer Dim t As Single Dim s As Single Dim a(10) As Single For i = 1 To 10 a(i) = InputBox("请输入第" & i & "个数") Print a(i); NextFor i = 1 To 9 For j = i To 10 If a(i) > a(j) Then t =...
郾城县15320301034: VB评分软件 去掉最高、最低分 - ?
景雄鼻炎: Private Sub Command1_Click() Dim arry1(9) As Variant For i = 0 To 9 arry1(i) = Val(Text1(i).Text) Next '对数组排序 Dim w1, w2 As Integer Dim temp1 As Variant For w1 = 0 To UBound(arry1()) - 1 For w2 = w1 + 1 To UBound(arry1()) 罚伐窜和诃古...
郾城县15320301034: 我想用vb设计一个程序:用一组数中的最大值减去最小值后,再除以这组数的的平均数,不过我不会,急!@!谢 - ?
景雄鼻炎: Dim i, max, min, avg, sum As IntegerFor i = 0 to UBound(数组回答)If i = 0 Thenmin = 数组(0)max = 数组(0)End IfIf max < 数组(i) thenmax = 数组(i)End ifIf min > 数组(i) thenmin = 数组(i)End ifsum = sum + 数组(i) Next iDebug.Print cstr((max-min)/(sum/(UBound(数组)+1)))
郾城县15320301034: 利用VB编程,输入十个评委给出的分数,去掉最大值与最小值,计算最后的平均值并输出. - ?
景雄鼻炎: 添加一个Command1,10个text,分别为text1(0),text1(1).....text1(9),用来输入10个评委的分数,1个text2输出结果.Private Sub Command1_Click() Dim MaxT, MinT, SumT As Long MaxT = Text1(0).Text MinT = Text1(0).Text SumT = 0 For i = 0 To ...
郾城县15320301034: 用VB设计个竞赛评分系统,该系统能显示评委分数,去掉最高分最低分,最后输出选手的平均得分 - ?
景雄鼻炎: 将每位评委的得分排序,去掉最大和最小,然后进行平均计算即可.
郾城县15320301034: VB 随机产生10个0~100之间的随机整数,去掉最大值与最小值,剩下8个数的和与平均数.VB - ?
景雄鼻炎:[答案] 帮你写好了,这个是工程文件,下载下来就可以了.以下是源码:Private Sub Command1_Click()Dim A(10) As Double, L As Integer, B As Double, C As Double, D As DoubleRandomize '根据时间初始化随机数A(0) = (Rnd...
郾城县15320301034: VB程序设计中,有10个分数,怎样输入一个除去最大值、最小值,求平均值的程序?急! - ?
景雄鼻炎: 先在窗体上放一个text1,在界面将text1的index属性值设为0,这样我们就创建了一个textbox控件数组,用复制粘贴的办法再添加9个成员 再在窗体上放3个按纽控件,代码如下:Option Explicit: Dim a(9) As Integer, s As Double, max As Integer, ...