主题:请大家帮我打印下面的图形(二维数组)谢谢.........
chenhonghong
[专家分:70] 发布于 2006-05-14 17:09:00
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
回复列表 (共10个回复)
沙发
求救 [专家分:40] 发布于 2006-05-14 22:28:00
dim a(5,5) as integer
for i=1 to 5
a(i,1)=1
a(i,j)=1
next i
for i=3 to 5
for j=2 to i-1
a(i,j)=a(i-1,j-1)+a(i-1,j)
next j
next i
for i=1 to 5
print tab(6-i);
for j=1 to i
if j=i then
print right$(str$(a(i,j)),1)
else
print right$(str$(a(i,j)),1);" ";
end if
next j
print
next i
end
板凳
求救 [专家分:40] 发布于 2006-05-14 22:30:00
上面有一点打错了
dim a(5,5) as integer
for i=1 to 5
a(i,1)=1
a(i,i)=1
next i
for i=3 to 5
for j=2 to i-1
a(i,j)=a(i-1,j-1)+a(i-1,j)
next j
next i
for i=1 to 5
print tab(6-i);
for j=1 to i
if j=i then
print right$(str$(a(i,j)),1)
else
print right$(str$(a(i,j)),1);" ";
end if
next j
print
next i
end
3 楼
求救 [专家分:40] 发布于 2006-05-14 22:40:00
上面是字符输出相隔的空格小
下面是数字输出相隔的空格大
dim a(5,5) as integer
for i=1 to 5
a(i,1)=1
a(i,i)=1
next i
for i=3 to 5
for j=2 to i-1
a(i,j)=a(i-1,j-1)+a(i-1,j)
next j
next i
for i=1 to 5
print tab(12-2*i-1);
for j=1 to i
if j=i then
print a(i,j);
else
print a(i,j);" ";
end if
next j
print
next i
end
4 楼
风吹过 [专家分:30] 发布于 2006-05-17 08:34:00
cls
dim a(5,5)
a(1,1)=1
for i=2 to 5
for j=1 to i
a(i,j)=a(i-1,j-1)+a(i-1,j)
next j,i
for i=1 to 5
print tab (30-2*i);
for j=1 to i
print a(i,j)
next j
print
next i
end
5 楼
小小傻瓜 [专家分:150] 发布于 2007-07-27 16:56:00
杨辉三角形
dim a(10,10)
a(1,1)=1
for i=2 to 10
for j=1 to i
a(i,j)=a(i-1,j-1)+a(i-1,j)
next j,i
for i=1 to 10
print tab (40-2*i);
for j=1 to i
print using"######";a(i,j); '输出更美观
next j
print
next i
end
6 楼
wzc1996 [专家分:1680] 发布于 2007-07-28 08:26:00
cls
dim x(10,10)
x(1,1)=1
for i=2 to 10
for j=1 to i
x(i,j)=x(i-1,j-1)+x(i-1,j)
next j,i
for i=1 to 10
print tab (40-2*i);
for j=1 to i
print using"######";x(i,j);
next j
print
next i
7 楼
wzc1996 [专家分:1680] 发布于 2007-07-28 08:27:00
8 楼
lzh609754893 [专家分:20] 发布于 2008-11-17 21:09:00
小菜路过'''
我也发一个:
cls
dim a(5,5)
for i = 1 to 5
a(i,1)=1
a(i,i)=1
next
for i = 3 to 5
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 5
print tab(6-i);
for j=1 to i
print a(i,j)
next j
print
next i
end
9 楼
ZHANGHONGCHENG [专家分:70] 发布于 2008-11-20 22:00:00
俺也来试试
CLS
INPUT N
DIM A(N,N)
A(0,0)=0
A(0,1)=1
FOR I=1 TO N
PRINT TAB(N+1-I);
FOR J=1 TO I
A(I,J)=A(I-1,J-1)+A(I-1,J)
PRINT USING"##";A(I,J);
NEXT J
NEXT I
END
10 楼
593170024 [专家分:500] 发布于 2009-10-27 23:13:00
只有我的对,最简单,通用的 n= 行
input n
dim a(n,n)
a(1,1)=1
?tab (n);a(1,1)
for i=2 to n
print tab(n-i);
for j=1 to i
a(i,j)=a(i-1,j-1)+a(i-1,j)
print using"#"; a(i,j);
next j,i
end
我来回复