作业帮 > 数学 > 作业

以下程序段执行后整型变量n 的值为 n=0 for i=1 to 20 step 5 n=n+i next I A.50

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:数学作业 时间:2024/04/27 04:50:36
以下程序段执行后整型变量n 的值为 n=0 for i=1 to 20 step 5 n=n+i next I A.50 B.34 C.15 D.210
求C的值
if a>5 then
if b3 then c=a*b else c=a mod b end if
A.2 B.-1 C.1 D.6
这题也请说明下
以下程序段执行后整型变量n 的值为 n=0 for i=1 to 20 step 5 n=n+i next I A.50
n=34,
for循环过程(i 每次加5):
i=1,n=0+1=1
i=6,n=1+6=7
i=11,n=7+11=18
i=16,n=18+16=34
第二道题不知道a和b的初始值,没法计算.
再问: 不好意思 a=2,b=3
再答: 首先,a=2,那麼if a>5不成立, 程序跳过 if b3 then c=a*b else c=a mod b 这一段,在这个 if 语句中, b=3,b>3不成立,所以执行else语句,也就是 c=a mod b,c=2 mod 3 =2, 所以,c=2