程序算法里面的问题 for i =1 to 20 step 2 for j = i to 20 step 3
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/12 13:21:48
程序算法里面的问题 for i =1 to 20 step 2 for j = i to 20 step 3
private sub command1_click()
dim i,j,x
for i = 1 to 20 step 2
x=0
for j = i to 20 step 3
x=x+1
next j
next i
text1.value=str(x)
end sub
请问j到底是怎么执行的?
还有在这个步长什么的算法里,如果step后面数字是负的 到底能不能执行
private sub command1_click()
dim i,j,x
for i = 1 to 20 step 2
x=0
for j = i to 20 step 3
x=x+1
next j
next i
text1.value=str(x)
end sub
请问j到底是怎么执行的?
还有在这个步长什么的算法里,如果step后面数字是负的 到底能不能执行
如果步长为负数,那么for i = 1 to 20,执行,但是死循环.
步长你可以理解为等差
譬如第一次i = 1,步长为2,那下一次就是i+2 = 3,下一次就是5,依此类推,明白了没有?
再问: 那我上面打出的这道题目呢?j= i to 20 step 3 i是个变量怎么办
再答: 你的是vb for i = 1 to 20 step 2 x=0 解释下当i=1的处理 for j = i to 20 step 3 --> j =1---> 20, step = 3 这里执行是从1到20,每次增加3, x=x+1 next j next i
再问: 那答案为什么是1? 我还是不太懂
再答: 我把每一次循环过程都给你写出来了,你分析下 i = 1, j =1, x = 1 i = 1, j =4, x = 2 i = 1, j =7, x = 3 i = 1, j =10, x = 4 i = 1, j =13, x = 5 i = 1, j =16, x = 6 i = 1, j =19, x = 7 i = 3, j =3, x = 1 i = 3, j =6, x = 2 i = 3, j =9, x = 3 i = 3, j =12, x = 4 i = 3, j =15, x = 5 i = 3, j =18, x = 6 i = 5, j =5, x = 1 i = 5, j =8, x = 2 i = 5, j =11, x = 3 i = 5, j =14, x = 4 i = 5, j =17, x = 5 i = 5, j =20, x = 6 i = 7, j =7, x = 1 i = 7, j =10, x = 2 i = 7, j =13, x = 3 i = 7, j =16, x = 4 i = 7, j =19, x = 5 i = 9, j =9, x = 1 i = 9, j =12, x = 2 i = 9, j =15, x = 3 i = 9, j =18, x = 4 i = 11, j =11, x = 1 i = 11, j =14, x = 2 i = 11, j =17, x = 3 i = 11, j =20, x = 4 i = 13, j =13, x = 1 i = 13, j =16, x = 2 i = 13, j =19, x = 3 i = 15, j =15, x = 1 i = 15, j =18, x = 2 i = 17, j =17, x = 1 i = 17, j =20, x = 2 i = 19, j =19, x = 1 1
步长你可以理解为等差
譬如第一次i = 1,步长为2,那下一次就是i+2 = 3,下一次就是5,依此类推,明白了没有?
再问: 那我上面打出的这道题目呢?j= i to 20 step 3 i是个变量怎么办
再答: 你的是vb for i = 1 to 20 step 2 x=0 解释下当i=1的处理 for j = i to 20 step 3 --> j =1---> 20, step = 3 这里执行是从1到20,每次增加3, x=x+1 next j next i
再问: 那答案为什么是1? 我还是不太懂
再答: 我把每一次循环过程都给你写出来了,你分析下 i = 1, j =1, x = 1 i = 1, j =4, x = 2 i = 1, j =7, x = 3 i = 1, j =10, x = 4 i = 1, j =13, x = 5 i = 1, j =16, x = 6 i = 1, j =19, x = 7 i = 3, j =3, x = 1 i = 3, j =6, x = 2 i = 3, j =9, x = 3 i = 3, j =12, x = 4 i = 3, j =15, x = 5 i = 3, j =18, x = 6 i = 5, j =5, x = 1 i = 5, j =8, x = 2 i = 5, j =11, x = 3 i = 5, j =14, x = 4 i = 5, j =17, x = 5 i = 5, j =20, x = 6 i = 7, j =7, x = 1 i = 7, j =10, x = 2 i = 7, j =13, x = 3 i = 7, j =16, x = 4 i = 7, j =19, x = 5 i = 9, j =9, x = 1 i = 9, j =12, x = 2 i = 9, j =15, x = 3 i = 9, j =18, x = 4 i = 11, j =11, x = 1 i = 11, j =14, x = 2 i = 11, j =17, x = 3 i = 11, j =20, x = 4 i = 13, j =13, x = 1 i = 13, j =16, x = 2 i = 13, j =19, x = 3 i = 15, j =15, x = 1 i = 15, j =18, x = 2 i = 17, j =17, x = 1 i = 17, j =20, x = 2 i = 19, j =19, x = 1 1
程序算法里面的问题 for i =1 to 20 step 2 for j = i to 20 step 3
30.for i=1 to 12 step 3 40 for j=6 to 2 step-2 41 print i;j
在计算机题里面,编程中有一句For i=1 To 20 step 3,
程序在运行循环“For I=1 to 14 step 3”结束后,I=?
假定有以下程序段 n=0 for i=1to4 for j =3 to -1 step -1 n=n+1 next j
执行下面程序后 X的值 X=5 for i = 1 to 20 step 2 X=X +i\5 next i
若有一段VB程序如下 For i =4 to 20 step x
For i=1 to 6 step 2
J = 10 For I = 1 To J Step 5 I = I + 2 J = J - I Next I Prin
执行下面的程序段后,x 的值为( ). x=5 For i=1 To 20 Step 2 x=x+i\5
语句:For i =-3 to 20 step 4的循环次数是好多?
vb求教:for i=3 to 20 step 4的循环次数是多少?