Task

Produce a formatted   12×12   multiplication table of the kind memorized by rote when in primary (or elementary) school.



Only print the top half triangle of products.




 
MODULE MultiplicationTables;
 
FROM SWholeIO IMPORT
  WriteInt;
FROM STextIO IMPORT
  WriteString, WriteLn;
 
CONST
  N = 12;
 
VAR
  I, J: INTEGER;
 
BEGIN
  FOR J := 1 TO N - 1 DO
    WriteInt(J, 3);
    WriteString(" ");
  END;
  WriteInt(N, 3);
  WriteLn;
  FOR J := 0 TO N - 1 DO
    WriteString("----");
  END;
  WriteString("+");
  WriteLn;
  FOR I := 1 TO N DO
    FOR J := 1 TO N DO
      IF J < I THEN
        WriteString("    ");
      ELSE
        WriteInt(I * J, 3);
        WriteString(" ");
      END;
    END;
    WriteString("| ");
    WriteInt(I, 2);
    WriteLn;
  END;
END MultiplicationTables.
 