一堆IKUN知识点

(1)输出前n个catalan数:
program jk;
const maxn=1000;
type arraytype=array[0..maxn] of longint;
var i,j,n:longint;

procedure mul(var h:arraytype;k:longint);
var i:longint;
  begin
    for i:=0 to maxn do h[i]:=h[i]*k;
    for i:=0 to maxn-1 do
    begin
      h[i+1]:=h[i+1]+h[i] div 10;
      h[i]:=h[i] mod 10
    end
  end;

procedure devide(var h:arraytype;k:longint);
var d,i,r:longint;
  begin
  r:=0;
  for i:=maxn downto 0 do
    begin
      d:=10*r+h[i];
      h[i]:=d div k;
      r:=d mod k
    end
  end;
procedure cat(n:integer);
var i,j:integer;
    h:arraytype;
begin
for i:=1 to maxn do h[i]:=0;
  h[0]:=1;
  for i:=3 to n-1 do
    begin
      mul(h,4*i-6);
      devide(h,i

你可能感兴趣的:(干货,算法,c++,开发语言)