下标越界dim .for i = 1 to 7for j = 1 to 7 if i = 1 or j = 1 then a(i,j)=1elsea(i,j) =a(i-1,j-1)+a(i-1,j)end ifnext j next ifor i= 1 to7for j= 1 to iprint a(i,j)next j printnext i .运行说是下标越界 a(i,j) =a(i-1,j-1
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 08:02:22
下标越界dim .for i = 1 to 7for j = 1 to 7 if i = 1 or j = 1 then a(i,j)=1elsea(i,j) =a(i-1,j-1)+a(i-1,j)end ifnext j next ifor i= 1 to7for j= 1 to iprint a(i,j)next j printnext i .运行说是下标越界 a(i,j) =a(i-1,j-1
下标越界
dim .
for i = 1 to 7
for j = 1 to 7
if i = 1 or j = 1 then a(i,j)=1
else
a(i,j) =a(i-1,j-1)+a(i-1,j)
end if
next j
next i
for i= 1 to7
for j= 1 to i
print a(i,j)
next j
print
next i
.
运行说是下标越界 a(i,j) =a(i-1,j-1)+a(i-1,j) 说是这句话 不懂怎么错的啊 求教
下标越界dim .for i = 1 to 7for j = 1 to 7 if i = 1 or j = 1 then a(i,j)=1elsea(i,j) =a(i-1,j-1)+a(i-1,j)end ifnext j next ifor i= 1 to7for j= 1 to iprint a(i,j)next j printnext i .运行说是下标越界 a(i,j) =a(i-1,j-1
问题一定出在数组的dim上,帮你完整地写了一下:
Private Sub Command1_Click()
Dim a(7, 7) As Integer
For i = 1 To 7
For j = 1 To 7
If i = 1 Or j = 1 Then
a(i, j) = 1
Else
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
End If
Next j
Next i
For i = 1 To 7
For j = 1 To i
Print a(i, j);
Next j
Print
Next i
End Sub