初学者内容写详细点。感激啦!
1   
1   1
1   2   1   
1   3   3   1   
1   4   6   4   1   
1   5   10  10  5   1   
1   6   15  20  15  6   1   
1   7   21  35  35  21  7   1   
1   8   28  56  70  56  28  8   1   
1   9   36  84  126 126 84  36  9   1

解决方案 »

  1.   

    这会有时间正好写一个,就是用到了二维数组。declare
      type t_type is table of number index by binary_integer;
      type tt_type is table of t_type index by binary_integer;
      n        number := &n;
      tt_array tt_type;
    begin  tt_array(1)(1) := 1;
      tt_array(2)(1) := 1;
      tt_array(2)(2) := 1;  for i in 3 .. n loop
        tt_array(i)(1) := 1;
        for j in 2 .. i - 1 loop
          tt_array(i)(j) := tt_array(i - 1) (j - 1) + tt_array(i - 1) (j);
        end loop;
        tt_array(i)(i) := 1;
      end loop;  for i in 1 .. tt_array.count loop
        for j in 1 .. i loop
          dbms_output.put(tt_array(i) (j));
          dbms_output.put(' ');
        
        end loop;
        dbms_output.put_line('');
      end loop;end;
      

  2.   

    declare
    type yiwei is table of int index by binary_integer ;
    type erweizhu is table of yiwei index by binary_integer;
    er erweizhu;
    begin
    for i in 1..&aa loop
    for j in 1..i loop
    if  i=j then er(i)(j):=1;
    dbms_output.put_line(er(i)(j));
    elsif j=1 then er(i)(j):=1;
    dbms_output.put(er(i)(j));
    else 
    er(i)(j):=er(i-1)(j)+er(i-1)(j-1);
    dbms_output.put(er(i)(j));
    end if ;
    end loop;
    end loop;
    end;
      

  3.   

    --输出杨辉三角
    begin
      for i in 1..11 loop
        for j in 1..i loop
          dbms_output.put(rpad(to_char(getNum(i,j)),5,' '));
        end loop;
        dbms_output.put_line('');
      end loop;
    end;
    --自定义根据位置确定杨辉三角中的值
    create or replace function getNum(i number,j number)
    return number
    is
    begin
      if((j = 1) or (j = i)) then
            return 1;
      else
        return getNum(i-1,j-1) + getNum(i-1,j);
      end if;
      return 0;
    end;