用VFP求纵向输入“计算机等级考试”(用循环语句)并将第五行的字符输出给定变量OUT。

来源:百度知道 编辑:UC知道 时间:2024/06/28 22:47:09

set talk off
dime S(7)
for i=1 to 7
accept "第"+str(i,1)+"个字:" to S(i)
endf
out = S(5)
? out
retu

LOCAL out
cstr="计算机等级考试"
for i=1 to 7
a=substr(cstr,2*i-1,2)
?a
if i=5
out=a
ENDIF
IF i=8
RETURN out
endif
endfor
?"out="
?out

或者用公共变量
public out
cstr="计算机等级考试"
for i=1 to 7
a=substr(cstr,2*i-1,2)
?a
if i=5
out=a
ENDIF
endfor
?"out="
?out