注意:定义数组里面的字符要加引号,取余要用mod,等于就是=,asp只能用form表单获取值,而且好像不可以动态获取form表单的值,我发现数组定义的时候str(8)就可以保存9个值
<% '判断是否能进入重点大学:满足条件1、语数外全A,其他6门只有1个C,四个A。2、语数外有一个B两个A,其他6门6个A'
'获取值'
dim str(8)
str(0)=request.form("chinese")
str(1)=request.form("math")
str(2)=request.form("english")
str(3)=request.form("physics")
str(4)=request.form("chemistry")
str(5)=request.form("biology")
str(6)=request.form("political")
str(7)=request.form("history")
str(8)=request.form("geography")
'循环分数改成等级,分为A,B,C,D,和其他(如果是其他则赋值为空)'
for i=0 to 8
if str(i)>=90 then
str(i)="A"
elseif str(i)>=85 and str(i)<90 then
str(i)="B"
elseif str(i)>=70 and str(i)<85 then
str(i)="C"
elseif str(i)>0 then
str(i)="D"
else
str(i)=""
end if
next
'循环数组,A则加100,B则加10,C则加1,D不处理,空值的时候将flag=0'
dim b,c,flag
flag=1
for i=0 to 2
if str(i)="A" then
b=b+100
elseif str(i)="B" then
b=b+10
elseif str(i)="C" then
b=b+1
elseif str(i)="D" then
else
flag=0
end if
next
for i=3 to 8
if str(i)="A" then
c=c+100
elseif str(i)="B" then
c=c+10
elseif str(i)="C" then
c=c+1
elseif str(i)="D" then
else
flag=0
end if
next
'flag=0时说明没有完整的输入分数'
if (b=300 and c mod 10<=1 and c>=411 and flag=1) or (b=210 and c=600 and flag=1) then
response.write ("能进入重点大学")
elseif flag=0 then
response.write "请输入全部的成绩"
else
response.write "不能进入重点大学"
end if
%>