vfp 编程 S=1-1/2+1/3-1/4+1/5-...-1/100

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/06 09:34:36
vfp编程S=1-1/2+1/3-1/4+1/5-...-1/100vfp编程S=1-1/2+1/3-1/4+1/5-...-1/100vfp编程S=1-1/2+1/3-1/4+1/5-...-1/1

vfp 编程 S=1-1/2+1/3-1/4+1/5-...-1/100
vfp 编程 S=1-1/2+1/3-1/4+1/5-...-1/100

vfp 编程 S=1-1/2+1/3-1/4+1/5-...-1/100
经过调试,可以写如下代码:
clear
S=0
for i= 1 to 100
if mod(i,2)=0
x=x-1/i
else
x=x+1/i
endif
endfor
"S=",s