pascal高手求救 (6)输入正整数N,打印杨辉三角形的前N行。
3个回答
展开全部
var
a:array[1..10,1..10]of longint;
i,j,n:longint;
begin
readln(n);
for i:=1 to n do begin
a[i,1]:=1; a[i,i]:=1; end;
for i:=3 to n do
for j:=2 to n-1 do
a[i,j]:=a[i-1,j]+a[i-1,j-1];
for i:=1 to n do begin
write(a[i,1]:30-2*i);
for j:=2 to i do write(a[i,j]:4);
writeln;
end;
readln;
end.
求给分!
a:array[1..10,1..10]of longint;
i,j,n:longint;
begin
readln(n);
for i:=1 to n do begin
a[i,1]:=1; a[i,i]:=1; end;
for i:=3 to n do
for j:=2 to n-1 do
a[i,j]:=a[i-1,j]+a[i-1,j-1];
for i:=1 to n do begin
write(a[i,1]:30-2*i);
for j:=2 to i do write(a[i,j]:4);
writeln;
end;
readln;
end.
求给分!
展开全部
已进行编译,未处理间距,0≤N≤34。。。
var i,j,k,l,m,n:longint;
a:array [0..1000,0..1000] of longint;
begin
read(n);
a[1,1]:=1;
if n>=1 then write(1);
for i:=1 to n do
begin
for j:=1 to i do
if not((i=1)and(j=1)) then
begin
a[i,j]:=a[i-1,j]+a[i-1,j-1];
write(a[i,j],' ');
end;
writeln;
end;
end.
var i,j,k,l,m,n:longint;
a:array [0..1000,0..1000] of longint;
begin
read(n);
a[1,1]:=1;
if n>=1 then write(1);
for i:=1 to n do
begin
for j:=1 to i do
if not((i=1)and(j=1)) then
begin
a[i,j]:=a[i-1,j]+a[i-1,j-1];
write(a[i,j],' ');
end;
writeln;
end;
end.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var
n,i,j:longint;
a:array[0..127] of longint;
begin
readln(n);
a[0]:=1;
for i:=0 to n -1 do begin
for j:=i downto 1 do a[j]+=a[j-1];
for j:=0 to i do write(a[j]:6); writeln;
end;
end.
n,i,j:longint;
a:array[0..127] of longint;
begin
readln(n);
a[0]:=1;
for i:=0 to n -1 do begin
for j:=i downto 1 do a[j]+=a[j-1];
for j:=0 to i do write(a[j]:6); writeln;
end;
end.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询