Dim a(6)
for i=0 to 6
a(i)=i+1
next
for i=0 to 6
count=count+a(i)+1
next
response.write count
谁能帮我详细的解释下代码,最后输出的结果又是什么
Dim a(6)
for i=0 to 6
a(i)=i+1
next
for i=0 to 6
count=count+a(i)+1
next
response.write count
谁能帮我详细的解释下代码,最后输出的结果又是什么
<%
Dim a(6)'数组,从a(0)-a(7)
for i=0 to 6'循环7次
a(i)=i+1
'给数组赋值,运行过程
'第一次循环,a(1)=1+1=2
'第二次循环,a(2)=2+1=3
'第三次循环,a(3)=3+1=4
'第四次循环,a(4)=4+1=5
'第五次循环,a(5)=5+1=6
'第六次循环,a(6)=6+1=7
'第七次循环,a(7)=7+1=8
next
'利用循环非别给a(0)-a(7)赋了值
for i=0 to 6'又一个循环,也是7次
count=count+a(i)+1
'变量count默认为0,运行过程
'count=0+2+1=3
'count=0+3+1=4
'count=0+4+1=5
'count=0+5+1=6
'count=0+6+1=7
'count=0+7+1=8
'count=0+8+1=9
next
'最后变量count的值为9
response.write count
%>
Dim a(6)//定义一个6位数组
for i=0 to 6
a(i)=i+1 //利用循环给数组赋值 a(0)=1、a(1)=2、a(2)=3、a(3)=4、a(4)=5、a(5)=6
next
for i=0 to 6
count=count+a(i)+1 //利用循环计算数组的和+6
next
response.write count//输出结果27
Dim a(6) '声明数组
for i=0 to 6 'FOR语句,循环从0到6目的是便利数组
a(i)=i+1 '对数组每个对象赋值
next 'FOR结束
for i=0 to 6 'FOR语句,循环从0到6目的是对变量count进行累加
count=count+a(i)+1 '变量count的累加,其中a(i)是取得数组中的值
next 'FOR结束
response.write count '输出
结果:35