当年写大学生英语评分系统时的一段程序,用asp实现的去掉最高分,最低分,后求总分平均分.当时也是在网上找到好多代码参考学习后,再研究,结合项目需要,制作出来的,供参考.
'下面是求最高分
maxarr = arr(0)
for i = 1 to ubound(arr)
if arr(i) > maxarr then'a(i)比最大的还大
temp = maxarr
maxarr = arr(i)
end if
next
response.Write("<br>最高分为:"&maxarr& " ")
'下面求最低分
minarr=arr(0)
for i = 1 to ubound(arr)
if arr(i) < minarr then 'a(i)比最小的还小
temp = minarr
minarr = arr(i)
end if
next
response.Write("最低分为:"&minarr&" ")
call DeleteMax(UBound(Arr),1)'删除1个最大的数!
call GetBack()'每个数称以-1将最小的数变成最大的数!
call DeleteMax(UBound(Arr),1)'删除称以-1以后1个最大的数!
call GetBack()'还原每一个数
sub DeleteMax(Arr_total,willdelete)
for m= 1 to willdelete
for i= 0 to Arr_total-m
if Arr(i)>Arr(i+1) then
call swap(Arr(i),Arr(i+1))
end if
next
ReDim Preserve Arr(Arr_total-m)
next
end sub
sub swap(num_a,num_b)'交换两个数
x=num_a
num_a=num_b
num_b=x
end sub
sub GetBack()
for L=0 to UBound(Arr)
Arr(L)=Arr(L)*-1
next
end sub
for j= 0 to UBound(Arr)'去掉极值后计算总分
zhongfen2=FormatNumber(zhongfen2+arr(j),2)
next
pingjunfen2=FormatNumber(cdbl(zhongfen2/(pingweishu-2)),2)
response.write "<br><font color='blue'>去掉一个最高分,去掉一个最低分后!</font><br>总分为:<font color='red' size='+4'>"&zhongfen2&"</font>  平均分为:<font color='red' size='+4'>"&pingjunfen2&"</font>"
session("pingjunfen")=pingjunfen2
end if