题目内容
右图是一个算法的程序框图,该算法输出的结果是
A. | B. |
C. | D. |
C
解:i=1,满足条件i<4,执行循环体;
i=2,m=1,n="1" (1×2) ,满足条件i<4,执行循环体;
i=3,m=2,n="1" (1×2) +1 (2×3) ,满足条件i<4,执行循环体;
i=4,m=3,n="1" (1×2) +1 (2×3) +1 (3×4) ,不满足条件i<4,退出循环体,
最后输出n="1" (1×2) +1 (2×3) +1 (3×4) =1-1 4 =3 4故选:C
i=2,m=1,n="1" (1×2) ,满足条件i<4,执行循环体;
i=3,m=2,n="1" (1×2) +1 (2×3) ,满足条件i<4,执行循环体;
i=4,m=3,n="1" (1×2) +1 (2×3) +1 (3×4) ,不满足条件i<4,退出循环体,
最后输出n="1" (1×2) +1 (2×3) +1 (3×4) =1-1 4 =3 4故选:C
练习册系列答案
相关题目