用VF编写程序,已知:S=1+3+5+7+9+…,求S不大于1000的最大值.答案是961.请亲测再传程序...

来源:学生作业学帮网 编辑:学帮网 时间:2024/06/04 13:45:29

用VF编写程序,已知:S=1+3+5+7+9+…,求S不大于1000的最大值.答案是961.请亲测再传程序...

s=0
for i=1 to 1000 step 2
s=s+i
if s>1000
?s-i
exit
endif
endfor
return