早教吧 育儿知识 作业答案 考试题库 百科 知识分享

下列程序段的执行结果为(未填).vb下列程序段的执行结果为(未填)。Dima(3,5)AsIntegerDimiAsInteger,jAsIntegerFori=1To3Forj=1To5a(i,j)=a(i-1,j-1)+(i-1)*3+jNextjNextiPrinta(3,4)错

题目详情
下列程序段的执行结果为( 未填 ).vb
下列程序段的执行结果为( 未填 )。
Dim a(3, 5) As Integer
Dim i As Integer, j As Integer
For i = 1 To 3
For j = 1 To 5
a(i, j) = a(i - 1, j - 1) + (i - 1) * 3 + j
Next j
Next i
Print a(3, 4) 错误 正确答案:D
A. 出错
B. 12
C. 15
D. 18
▼优质解答
答案和解析
a(3,4)
=a(3-1,4-1)+(3-1)*3+4
=a(2,3)+10
=a(2-1,3-1)+(2-1)*3+3+10
=a(1,2)+16
=a(1-1,2-1)+(1-1)*3+2+16
=a(0,1)+18
=0+18
=18