用pascal实现杨辉三角

蒟蒻写法如下。。大佬请路过
  var n,m,i:longint;
        a:array[1..10000]of longint;
    begin
      read(n);
      if n mod 2=0 then
      begin
        m:=n*n ;
        a[n div 2]:=m-1;
        for i:= n div 2-1 downto 1 do
          a[i]:=a[i+1]-2;
        for i:=n div 2+1 to n do
          a[i]:=a[i-1]+2;
      end
      else
      begin
        m:=n*n;
        a[n div 2]:=m-2;
        for i:= n div 2-1 downto 1 do
          a[i]:=a[i+1]-2;
        for i:=n div 2+1 to n do
          a[i]:=a[i-1]+2;
      end;
      for i:=1 to n do
        write(a[i],' ');
end.

你可能感兴趣的:(用pascal实现杨辉三角)