《VF循环程序例题.docx》由会员分享,可在线阅读,更多相关《VF循环程序例题.docx(8页珍藏版)》请在三一办公上搜索。
1、VF循环程序例题例 7-22 求1!+2!+3!+.+20!的值CLEARS=0FOR N=1 TO 20T=1FOR M=1 TO NT=T*MENDFORS=S+TENDFOR?S编程打印由数字组成的图案,图案如下11 21 2 31 2 3 41 2 3 4 51 2 3 4 5 6 clearfor i=1 to 6for j=1 to i? jendfor?endfor10、编写程序,显示九九乘法口诀(1) 用dowhile语句编写set talk offcleari=1do while i<=9j=1do while j<=i?str(i,2)+*+str(j,1)+=+s
2、tr(i*j,2)j=j+1enddo?i=i+1enddoreturn(2) 用FOR语句编写set talk offclearz=0for i=1 to 9for j=1 to iz=i*j?i,*,j,zendfor?endfor另:set talk offclearz=0for i=1 to 9for j=1 to iz=i*j?str(i,2)+*+str(j,1)+=+str(z,2)endfor?endfor11、显示用*表示的金字塔(1) 正金字塔CLEARFOR I=1 TO 4FOR J=5-I TO 3+II, J SAY * & 在第i行 第j列输出一个*ENDFORE
3、NDFOR (2) 倒金字塔CLEARFOR I=1 TO 4FOR J=i+1 TO 9-II, J SAY *ENDFOR?ENDFOR clearFOR I=1 TO 3FOR J=1 TO 2*i-1_, 10-I+J SAY *ENDFORENDFOR 为 I 时,显示为 正三角为4-I时,显示为 倒三角9. 求S1+1/2+2/3+3/5. . . . . .前10项之和CleaS=0A=1B=1For i=1 to 10S=s+a/bT=aA=bB=t+bEndfor?s12.* * * * * * * * * * * * * * * * * * * * *输出图形*ClearFor i=1 to 4For j=1 to i?*Endfor?Endfor*CleaFor i=1 to 4For j=1 to 4-i? &有一个空格EndforFor j=1 to 2*i-1?*Endfor?Endfor*CleaFor i=1 to 4For j=1 to 4-i? &有一个空格EndforFor j=1 to i?*Endfor?Endfor