求出 1 到 5000 之间的能被 5 整除的前若干个偶数之和,当和大于 500 时程序退出。
大家帮忙看一些这样写对不对clear
s=0
for i=1 to 5000
do while i%5=0 and i%2=0
s=s+i
if s>500
exit
endif
endd
next
?s
clear s=0 for n=10 to 5000 step 10 s=s+n if s>500 exit endif endfor ?s
* 方法一 Clear S=0 For lnI=1 To 5000 If lnI%2=0 And lnI%5=0 S=S+lnI EndIf If S>500 EXIT EndIf EndFor ?S
* 方法二 Clear S=0 I=1 Do while I<=5000 If i%5=0 and i%2=0 s=s+i EndIf i=i+1 if s>500 exit endif EndDo ?s