vfp程序运算题目求解store 1 to odd,avv store 6 to k do proc1 with (odd),(avv),(k) odd,k procedure proc1 parameters a1,a2,a3 for k=1 to a3 if mod(k,2)=0 a1=a1+k else a2=a2+k end if next k endfunc 求变量odd,avv,k有答案称k=77是哪里来

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 14:21:49
vfp程序运算题目求解store 1 to odd,avv store 6 to k do proc1 with (odd),(avv),(k) odd,k procedure proc1 parameters a1,a2,a3 for k=1 to a3 if mod(k,2)=0 a1=a1+k else a2=a2+k end if next k endfunc 求变量odd,avv,k有答案称k=77是哪里来
x]n@ǯBM%x\pcFn02JH Ф 0(2\ƻB׻ J}w󟝙6ISw\F?t.a7)8S"Pb$QU9ۣk"0 aZ"S$"fp,$5  Q()E2O(1$hNL=&+! H--N҇ _7BwKh.8n1 ܻMR#O-OC`,ǿ044χJ%EfLfyCoS4#aRmdMb |DZ%c+\9?$@i9dlϘ"=ٕ:ss4'^gckCovV, r%.iuK#oP!d (;v~ Uy}/#͆rDIƱj:5qk茬`:s15@y<{hE&\:f}w_QHzZz-Xk5pa ʃcg&cLJTA6,;6.X"(kLs݌]7A)4g39fymlFH'kP

vfp程序运算题目求解store 1 to odd,avv store 6 to k do proc1 with (odd),(avv),(k) odd,k procedure proc1 parameters a1,a2,a3 for k=1 to a3 if mod(k,2)=0 a1=a1+k else a2=a2+k end if next k endfunc 求变量odd,avv,k有答案称k=77是哪里来
vfp程序运算题目求解
store 1 to odd,avv
store 6 to k
do proc1 with (odd),(avv),(k)
odd,k
procedure proc1
parameters a1,a2,a3
for k=1 to a3
if mod(k,2)=0
a1=a1+k
else
a2=a2+k
end if
next k
endfunc
求变量odd,avv,k
有答案称k=7
7是哪里来的

vfp程序运算题目求解store 1 to odd,avv store 6 to k do proc1 with (odd),(avv),(k) odd,k procedure proc1 parameters a1,a2,a3 for k=1 to a3 if mod(k,2)=0 a1=a1+k else a2=a2+k end if next k endfunc 求变量odd,avv,k有答案称k=77是哪里来
刚开始的时候K=6
根据你的程序,在子程序中,for语句的变量实际上就是for k = 1 to 6;
也就是说在所以执行for时,k会被重新赋值,k的值会从1开始,并每循环1次其值增加1,一直到7时,这时的k值才不再符合for的条件范围,for语句才会结束,所以k=7.
for语句中的变量值在for语句结束后,其值总是比结束的哪个值大1(默认参数条件下).