VFP编程题:求100以内所有奇数的和,程序怎么写?

如题所述

第1个回答  2009-12-31
有很多方法的,下面是一种
clear

sum=0
for i=1 to 100
if (i+1)/2=int(i+1)/2
sum=sum+i
endif
endfor
?"100以内所有奇数的和:",sum
第2个回答  2009-12-28
CLOSE ALL
CLEAR ALL
CLEAR

nTotal = 0
FOR nLoop_01 = 1 TO 99 STEP 2
nTotal = nTotal + nLoop_01
NEXT

?nTotal

RETURN

*** 屏显:2500本回答被提问者和网友采纳
第3个回答  2009-12-28
s=0
for i=1 to 99 step 2
s=s+i
endfor
?"s=",s
相似回答