我有一道简单的VisualFoxPro题不会做

来源:百度知道 编辑:UC知道 时间:2024/06/13 21:05:38
如何运用loop来显示1,2,4,5 (就是要把3给跳过)
我是这么做的,但答案总不对,只显示一个11,我不知道哪里出错了。
set talk off
clear
s=0
i=1
do while i<=4
s=s+i
i=i+1
if s=3
loop
endif
enddo
?s
set talk on
retu

我希望能有人能帮助我,谢谢你们了!

修改如下:

set talk off
clear
s=0
i=1
do while i<=5
if i=3
i=i+1
loop
endif
?i
s=s+i
i=i+1
enddo
?"1+2+4+5=",s
set talk on
return

if s=3 这是赋值,你修改成if s==3应该就可以了....

set talk off
clear
s=0
i=1
do while i<=4
s=s+i
i=i+1
if i=3 //if s=3 这个可不符合你说的
i=i+1 // 没做过VF题 只是就你说的意思改了一下
loop
endif
enddo
?s
set talk on
retu