1、11.终止 FOT/NEXT 循环的条件是: _2.决定 FOR/NEXT 循环次数的因素是循环变量的_,_,和步长。3.FOR/NEXT 循环的步长为_时可以省略。4.FOR I=A TO B STEP C,循环次数的表达式为 _.5.写出下面程序的结果。(1) For i=-5 to -11 step -3S=s+iPrint sNext (2) A$=”ls”For x=5 to 3 step -1A$=a$+a$Next xPrint mid$(a$,x,3)(3) for i=9 to 2 step -6i=i+2print i*2;next iprint i*2;(4) for i
2、=1 to 10if i2=i/2 then 40s=s+i40 nextprint s(5) p=1for a=10 to 2 step -2p=p*anext a?a,p(6) s$=”for i=65 to 70 step 2s$=s$+chr$(i)next print s$(7) c$=”1234”for i=1 to len(c$)n=n+val(mid$(c$,i)next print n(8) for x=0 to 100 step 2print xnext x程序循环了_次。(9) for x=-3 to 7 step 2print x;next (10) for x=8 t
3、o 7 step -2print x;next x(11) for x=2 to 7 step 2x=x+2print x;next x(12) for x=-2 to -7 step -2x=-x2print x;next x(13) for x=1.5 to 11 step 1.5print x;next x(14) for x%=1.5 to 15 step 1.5print x%;next x%(15) for i=1 to 10print I;i=i+1next i(16) for i=1 to 10print I;i=i*2next i(17) for a=1 to 5b=a*a+
4、1print a,bc=a*anext aprint “b=”;b,”c=”;c(18) for i=-5 to 5if i0 then x=x+i2if i=1 thenP=1Elseif i=2 thenP=2Elseif i=3 thenP=3ElseP=4End ifPrint ps=s+pnext iprint s(27) dim a(10)for i=1 to 10A(i)=i*10+iNext iPrint a(i-1);(28) dim a(10)for i=1 to 10A(i)=i*10+iNext iPrint a(6) mod a(5)(29) dim a(10)For
5、 i=1 to 10 step 2A(i)=i*10.5+iNext iPrint a(7);a(3)(30) dim a(5) as integerFor i=1 to 4A(i)=2*i-1Next iPrint a(a(i)+i)(31) dim a$(5)A$(1)=”A”:a$(2)=”B”For i=3 to 5A$(i)=a$(I-1)+a$(i-2)Print a$(i)Next i3(32) dim a(2)for i=-2 to 0A(abs(i)=i*2Next Print a(1);a(2)(33) dim a(5)for i=2 to 5A(i)=i-1A(a(i)=
6、i2Print a(a(i);Next i(34) dim a(10)For i=1 to 10A(i)=iNext iFor i=1 to 10A(i)=a(11-i):print a(i);Next i(35) for j=5 to 8A=a*10+jNext jPrint a(36) aa$=”43.2”:bb$=”98.7”Cc$=aa$+bb$Dd=val(cc$)Print dd(37) bb$=”Inviting a friend to dinner”M=len(bb$)For j=1 to mB$=mid$(bb$,j,1)If b$=”n” then x=x+1Next jP
7、rint x(38) option base 1b=array(“home”,”once”,”establish”)For i=1 to 3A=a+left(b(i),i)Next iPrint a6.计算 S=1+1/2+1/31/10S=0FOR TO_S=_NEXTPRINT S7.计算 S=(12)+(34)+(910)S=0FOR I=1 TO_S=S+_NEXT IPRINT S8.求 1100 奇数的平方和 ,即 S = 1 2 +3 2 + +992。FOR I=1 TO_S=S+_NEXT IPRINT “SUM=”; S9.输入任一字符串, 然后按相反次序打出来INPUT
8、A$M=_B$=“”FOR K=M TO 1 STEP-1B$=_C$=C$+B$NEXT KPRINT C$10.用子程序的方法求 2!+3!+4!的值S=0FOR T=2 TO 4S=S+PNEXT TPRINT “2!+3!4!=”; SENDP=1FOR K=1 TO_NEXT KNEXT K_11.输入一个较短的字符串,查找是否包含在字符串 “The COMPAQ Personal Computer BASIC”中,并指出短字符串在长字符中串中的位置。4AS=“The COMPAQ Personal Computer BASIC”N=LEN(AS)INPUT B$M=LEN(B$)F
9、OR I=1 TO_C$=MID$(_)IF C$=B$ THEN PRINT“YES”;I;:GOTO 100NEXT IPRINT“NO”12.有如下程序:For ii=1 to 146 step 3Print “a”;Next i程序运行后会打印( )A.146 个 a B.49 个 a C.73 个 a D.46 个 a13.选择题(1)在窗体上画一个名称为 Text1 的文本框和一个名称为 Command1 的命令按钮,然后编写如下事件过程:Private Sub Command1_Click()Dim i As Integer,n As IntegerFor I=0 To 50i=
10、i+3n=n+1If i10 Then exit forNextText1.Text=Str(n)End Sub 程序运行后,单击命令按钮,在文本框中显示的值是 A) 2 B) 3 D) 4 D) 5(2)设有如下程序:Option Base 0Private Sub Form_Click()Dim aDim i As Integera=Array(1,2,3,4,5,6,7,8,9)For i=0 To 3Print a(5-i);Next End Sub程序运行后,单击窗体,则在窗体上显示的是 A) 4 3 2 1 B) 5 4 3 2 C) 6 5 4 3 D) 7 6 5 4(3)在窗
11、体上画一个名称为 Commandl 的命令按钮,一个名称为 Labell 的标签,然后 编写如下事件过程: Private Sub Commandl_C1ick() S0 For i1 T0 15 x2*i 一 1 1f x Mod 30 Then ss 十 1 Nexti LabellCaption=s End Sub程序运行后,单击命令按钮,则标签中显示的内容是 A)1 B)5 C)27 D)45(4)在窗体上画一个名称为 Command1 的命令按钮,然后编写如下事件过程:Private Sub Command1_Click()For n = 1 To 20If n Mod 3 0 Th
12、en m = m + n 3Next nPrint nEnd Sub 程序运行后,如果单击命令按钮,则窗体上显示的内容是 A)15 B)18 C)21 D)2414.程序填空.(1)以下程序的功能是:生成 20 个 200 到300 之间的随机整数,输出其中能被 5 整除的数并求出它们的和。请填空。 Private Sub Commandl_C1ick() Fori1To 20 xInt(_*200+100) If_7 0 Then Print xSS 十 _ 83 End IfNext i Print “Sum”:S5 End Sub(2) 执行下面的程序段后,i 的值为 _ ,s 的值为_ 。s = 2For i = 3.2 To 4.9 Step 0.8s = s + 1 Next i