vb程序设计for循环练习.docVIP

  • 120
  • 0
  • 约4.16千字
  • 约 4页
  • 2017-05-12 发布于河南
  • 举报
vb程序设计for循环练习

1.终止FOT/NEXT循环的条件是:________ 2.决定FOR/NEXT循环次数的因素是循环变量的________,_______,和步长。 3.FOR/NEXT循环的步长为____时可以省略。 4.FOR I=A TO B STEP C,循环次数的表达式为 ________. 5.写出下面程序的结果。 (1) For i=-5 to -11 step -3 S=s+i Print s Next (2) A$=”ls” For x=5 to 3 step -1 A$=a$+a$ Next x Print mid$(a$,x,3) (3) for i=9 to 2 step -6 i=i+2 print i*2; next i print i*2; (4) for i=1 to 10 if i\2=i/2 then 40 s=s+i 40 next print s (5) p=1 for a=10 to 2 step -2 p=p*a next a ?a,p (6) s$=”” for i=65 to 70 step 2 s$=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 2 print x next x 程序循环了________次。 (9) for x=-3 to 7 step 2 print x; next (10) for x=8 to 7 step -2 print x; next x (11) for x=2 to 7 step 2 x=x+2 print x; next x (12) for x=-2 to -7 step -2 x=-x^2 print x; next x (13) for x=1.5 to 11 step 1.5 print x; next x (14) for x%=1.5 to 15 step 1.5 print x%; next x% (15) for i=1 to 10 print I; i=i+1 next i (16) for i=1 to 10 print I; i=i*2 next i (17) for a=1 to 5 b=a*a+1 print a,b c=a*a next a print “b=”;b,”c=”;c (18) for i=-5 to 5 if i0 then x=x+i if i0 then y=y+i next i print “x=”;x print “y=”;y (19) s=0:m=1 for k=1 to 100 s=s+m*k:m=-m next k print s (20) for i=2 to 1 step -1 print i next i print i (21) s=0 for i=1 to 5 y=rnd(1)+1 s=s+int(y) next print s (22) k=1:s=0 for i=1 to 5 s=s+k*i k=-k next i print s (23) for i=10 to 6 step -1 J=i Next i Print j;i (24) p=1 For a=10 to 2 step -2 P=p*a Next a Print a,p (25) x=1 For i=1 to 3 If k=1 then a=x*x If k=2 then a=x*x+1 If k=3 then a=x*x+2 Print a; Next i (26) s=0 For i=1 to 3 If i=1 then P=1 Elseif i=2 then P=2 Elseif i=3 then P=3 Else P=4 End if Print p s=s+p next i print s (27) for j=5 to 8 A=a*10+j Next j Print a (28) aa$=”43.2”:bb$=”98.7” Cc$=aa$+bb$ Dd=val(cc$) Print dd (29) bb$=”Inviting a friend to dinner” M=len(bb$) For j=1 to m B$=mid$(bb$,j,1) If b$=”n” then x=x+1 Next j Prin

文档评论(0)

1亿VIP精品文档

相关文档