1、实验五 循环结构和过程程序设计(实验指导书86页)1. CLEARUSE D:VFP素材KSCJSTORE 0 TO N,SSCAN S=S+数学N=N=1ENDSCAN ? 所有学生的数学总分:, S? 所有学生的数学平均分:,S/NUSECANCEL2. CLEARACCEPT 输入一个英文字符串: TO XN=0FOR I=1 TO LEN(X) IF SUBSTR(X,I,1)= B N=N+1 ENDIFENDFOR?英文字符B个数:,NCANCEL3. CLEARS=0FOR I=1 TO 1000 S=S+(-1)(I-1)*(1/(2*I-1)ENDFOR?S=,SCANCEL
2、4. CLEARS=0INPUT N= TO NFOR I=1 TO N T=0 FOR J=1 TO I T=T+J ENDFOR S=S+TENDFOR?S=,SCANCEL5. clears=0input n= to nfor i=1 to n step 3 t=1 for j=1 to i t=t*j endfor s=s+tendfor?s=,sCancel6.CLEARFOR I=1 TO 5?SPACE(6-i) FOR J=1 TO i? *ENDFORENDFORCANCEL7. * 主程序CLEARUSE D:VFP素材KSCJSTORE 0 TO S,NDO D: VFP素材GC?”总分:”,S?”平均分:”,S/NUSECANCEL* 过程 D: VFP素材GC.PRGSCAN S=S+数学+语文+英语+地理+化学 N=N+1ENDSCANRETURN8. CLEARDIMENSION A(4)FOR I=1 TO 4INPUT 第+STR(I,1)+个数 TO A(I)ENDFORSTORE A(1) TO SMAX,SMINFOR I=1 TO 4IF SMAXA(I) SMIN=A(I)ENDIFENDFOR?SMAX=,SMAX?SMIN=,SMINCANCEL