Dim I as integer,j as integer Dim Mat(10,10) as integer For I = 1 to 10 Mat(I,I) = 1 For j = 1 to I If j = 1 then Mat(I,j) = 1 Else Mat(I,j) = Mat(I-1,j-1) + Mat(I-1,j) End if Next Next For I = 1 to 10 For j = 1 to I Print Mat(I,j) & “ “; Next Print Next
以下是引用purana在2006-12-18 9:04:21的发言: Dim I as integer,j as integer Dim Mat(10,10) as integer For I = 1 to 10 Mat(I,I) = 1 For j = 1 to I If j = 1 then Mat(I,j) = 1 Else Mat(I,j) = Mat(I-1,j-1) + Mat(I-1,j) End if Next Next For I = 1 to 10 For j = 1 to I Print Mat(I,j) & “ “; Next Print Next
原来这个三角形的规律是这样的,刚开始没有找到规律所以无从下手
谢谢,已经运行正常
#6
2010-05-01 00:51
以下是引用purana在2006-12-18 09:04:21的发言:
Dim I as integer,j as integer
Dim Mat(10,10) as integer
For I = 1 to 10
Mat(I,I) = 1
For j = 1 to I
If j = 1 then
Mat(I,j) = 1
Else
Mat(I,j) = Mat(I-1,j-1) + Mat(I-1,j)
End if
Next
Next
For I = 1 to 10
For j = 1 to I
Print Mat(I,j) & “ “;
Next
Print
Next
dim a() as integer
n=val(inputbox(""))
redim a(n+1,n+1)
for i=0 to n
for j=0 to i
if i=j or j=0 then
a(i,j)=1
else
a(i,j)=a(i-1,j-1)+a(i-1,j)
endif
print tab(7*j);a(i,j);
next
next