<%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
for i=0 to 6
a=i+1
next
for i=0 to 6
count=count+a+1
next
response.write (count)%>
为什么这两段ASP代码的运行结果会不同?
为什么这两段ASP代码的运行结果会不同?
答案:4 悬赏:50
解决时间 2021-01-04 04:08
- 提问者网友:风华是一指流沙
- 2021-01-03 23:39
最佳答案
- 二级知识专家网友:输掉的尊严
- 2021-01-04 00:00
一
a(0)=1
a(1)=2
a(2)=3
a(3)=4
a(4)=5
a(5)=6
a(6)=7
count=1+1=2
count=2+2+1=5
count=5+3+1=9
count=9+4+1=14
count=14+5+1=20
count=20+6+1=27
count=27+7+1=35
count=35
二
a=0+1=1
a=1+1=2
a=2+1=3
a=3+1=4
a=4+1=5
a=5+1=6
a=6+1=7
最后a=7 没有累计加
count=7+1=8 循环7次 累加
count=8+7+1=16
count=16+7+1=24
count=24+7+1=32
count=32+7+1=40
count=40+7+1=48
count=48+7+1=56
最后count=56
a(0)=1
a(1)=2
a(2)=3
a(3)=4
a(4)=5
a(5)=6
a(6)=7
count=1+1=2
count=2+2+1=5
count=5+3+1=9
count=9+4+1=14
count=14+5+1=20
count=20+6+1=27
count=27+7+1=35
count=35
二
a=0+1=1
a=1+1=2
a=2+1=3
a=3+1=4
a=4+1=5
a=5+1=6
a=6+1=7
最后a=7 没有累计加
count=7+1=8 循环7次 累加
count=8+7+1=16
count=16+7+1=24
count=24+7+1=32
count=32+7+1=40
count=40+7+1=48
count=48+7+1=56
最后count=56
全部回答
- 1楼网友:怪咖小青年
- 2021-01-04 02:21
当然不同..
第一段是数组,A(0)~A(6)是渐渐增大的,可以说结果是A(0)+..+A(6)+1
第二段看起来你的A是不断在变化的.事实上你最后算的时候,只是算最后的A值.
也就是A+...+A+1
结果当然不同.全部都是加最后一个A
- 2楼网友:嗷呜我不好爱
- 2021-01-04 01:32
asp中for的结束标识是next
- 3楼网友:懂得ㄋ、沉默
- 2021-01-04 00:13
第一个程序:
a(0)=1;a(1)=2;a(2)=3;a(3)=4;a(4)=5;a(5)=6;a(6)=7.
第二个程序:
a=7
垒加的数不一样当然结果会不同。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯