-
dim a(8) as integer
private sub command1_click()'生成随机数“按钮。
randomize
for i = 1 to 8
a(i) = int(rnd * 31) +20= & a(i) &","
next i
end sub
private sub command2_click()'按正序显示。
for i = 1 to 8
for j = i to 8
if a(i) >a(j) then t = a(i): a(i) = a(j): a(j) = t
next j
next i
for i = 1 to 8
a(i) &","
next i
end sub
private sub command3_click()'以相反的顺序显示。
for i = 8 to 1 step -1= & a(i) &","
next i
end sub
是这个意思吗? 我的理解是,我不知道这是否正确。
-
command1 按正顺序排列,command2 按相反顺序排列。 将 text1 和 text2 的多行值设置为 true。 **下面:
option explicit
dim a(8) as integer
private sub command1_click()
dim i as integer, j as integer, n as long, s as string
for i = 0 to 7
for j = i to 7
if a(i) n = a(i)
a(i) = a(j)
a(j) = n
end if
next j
"a( " & cstr(i) &")=" & cstr(a(i)) " "
if i = 3 then = & chr(13) +chr(10)
next i
end sub
private sub command2_click()
dim i as integer, j as integer, n as long, s as string
for i = 0 to 7
for j = i to 7
if a(i) >a(j) then
n = a(j)
a(j) = a(i)
a(i) = n
end if
next j
"a( " & cstr(i) &")=" & cstr(a(i)) " "
if i = 3 then = & chr(13) +chr(10)
next i
end sub
private sub form_load()
randomize
dim i as integer
for i = 0 to 7
a(i) = int(rnd(1) *31) +20)
a(i)next i
end sub
-
知道有类似的问题,没有 1000,有一个像 100 这样的问题,汗。
-
如果 i 的值为奇数,则执行行 i=i+2。
i 的值为偶数,执行为 i=i+1
如果 k 小于或等于 15,则循环将执行 16 次。
i=1 k=0+1 i=3
i=3 k=1+3 i=5
i=5 k=4+5 i=7
i=7 k=9+7 i=9
k=16 对退出循环不满意。
-
a=9b=5
for i = 1 to a step 2 '循环运算从 1 开始,每次计算循环时 i 值为 + 2
b = b + a 3 '先乘除,再加减。
接下来 I '继续循环,直到 i 值的末尾大于 a,a = 9
因此,第一次输入循环结构时,i = 1 (b = 5 + 9 3) b 值为 8
循环结构的第二个条目 i = 3 (b = 8 + 9 3) b 值为 11
第三次进入循环结构时,i = 5 (b = 11 + 9 3),b 值为 14
循环结构的第 4 个条目 i = 7 (b = 14 + 9 3) b 值为 17
循环结构的第 5 个条目 i = 9 (b = 17 + 9 3) b 值为 20
在循环结束时,b 值为 20