求位大大帮忙用vb的一维数组且简单的编程语言编个杨辉三角的计算程序
3个回答
展开全部
Private Sub Command1_Click()
Dim a
n = InputBox("输入一个正整数")
ReDim a(n, n)
For i = 1 To n
For j = i To n
If i = j Then a(i, j) = 1
a(i, 1) = 1
Next j, i
For i = 2 To n
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n
For j = 1 To n
Print a(i, j); " ";
Next j
Print
Next i
End Sub
Dim a
n = InputBox("输入一个正整数")
ReDim a(n, n)
For i = 1 To n
For j = i To n
If i = j Then a(i, j) = 1
a(i, 1) = 1
Next j, i
For i = 2 To n
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n
For j = 1 To n
Print a(i, j); " ";
Next j
Next i
End Sub
追问
谢谢 虽然你是二维的 还是谢谢回答了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-03-25
展开全部
dim N as integer
N=inputbox("输入行数")
dim sz(20)
a(1)=1
for i=1 to N
print tab(40-2*i);a(1);
for j=I to 2 step -1
a(j)=a(j-1)+a(j)
print a(j);
next
a(I+1)=1
print a(I+1)
next
N=inputbox("输入行数")
dim sz(20)
a(1)=1
for i=1 to N
print tab(40-2*i);a(1);
for j=I to 2 step -1
a(j)=a(j-1)+a(j)
print a(j);
next
a(I+1)=1
print a(I+1)
next
追问
下标越界诶诶 咋办?
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不懂爱
更多追问追答
追问
好吧 谢谢
追答
我用易语言编程也遇到过差不多的问题,数组成员引用下标超出范围,
应该先判断一下a里面是否有内容
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询