solutions/cw4/pascal.while
changeset 959 64ec1884d860
equal deleted inserted replaced
958:fddf099a82f8 959:64ec1884d860
       
     1 rows := 13;
       
     2 coef := 1;
       
     3 
       
     4 i := 0;
       
     5 while (i < rows) do {
       
     6 
       
     7   space := 1;
       
     8 
       
     9   while (space <= rows - i) do {
       
    10       write("  ");
       
    11       space := space + 1
       
    12   };
       
    13 
       
    14   j := 0;
       
    15   while (j <= i) do {
       
    16 
       
    17       if ((j == 0) || i == 0) then {
       
    18         coef := 1
       
    19       } else {
       
    20         coef := (coef * ((i - j) + 1)) / j
       
    21       };
       
    22 
       
    23       if (coef < 10) then write("   ") else 
       
    24       if (coef < 100) then write("  ") else
       
    25       if (coef < 1000) then write(" ")
       
    26       else skip;
       
    27 
       
    28       write(coef);
       
    29       j := j + 1
       
    30   };
       
    31 
       
    32 
       
    33   write("\n");
       
    34   i := i + 1
       
    35 }