杨辉三角形用 pascal 来输出求程序 !急!!!
2个回答
展开全部
var
n,i,j:longint;
a:array[1..1000,1..1000] of longint;
begin
readln(n);
fillchar(a,sizeof(a),0);
for i:=1 to n do
a[i,1]:=1;
a[2,2]:=1;
for i:=3 to n do
for j:=1 to i do
a[i,j]:=a[i-1,j]+a[i-1,j-1];
for i:=1 to n do
begin
for j:=1 to n-i+2 do
write(' ');
for j:=1 to i do
write(a[i,j]:8);
writeln;
end;
end.
输入层数
n,i,j:longint;
a:array[1..1000,1..1000] of longint;
begin
readln(n);
fillchar(a,sizeof(a),0);
for i:=1 to n do
a[i,1]:=1;
a[2,2]:=1;
for i:=3 to n do
for j:=1 to i do
a[i,j]:=a[i-1,j]+a[i-1,j-1];
for i:=1 to n do
begin
for j:=1 to n-i+2 do
write(' ');
for j:=1 to i do
write(a[i,j]:8);
writeln;
end;
end.
输入层数
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询