载入中。。。 'S bLog
 
载入中。。。
 
载入中。。。
载入中。。。
载入中。。。
载入中。。。
载入中。。。
 
填写您的邮件地址,订阅我们的精彩内容:


 
用asp实现的去掉最高分,最低分,求总分平均分.
[ 2010/7/4 17:25:00 | By: 梦翔儿 ]
 

当年写大学生英语评分系统时的一段程序,用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& "&nbsp")
'下面求最低分
  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&"&nbsp")
 
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>&nbsp&nbsp平均分为:<font color='red' size='+4'>"&pingjunfen2&"</font>"

session("pingjunfen")=pingjunfen2

 end if

 
 
发表评论:
载入中。。。

 
 
 

梦翔儿网站 梦飞翔的地方 http://www.dreamflier.net
中华人民共和国信息产业部TCP/IP系统 备案序号:辽ICP备09000550号

Powered by Oblog.