Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. (*
  2.    adapted to Oberon-07 by 0CodErr, KolibriOS team
  3.                                                    *)
  4. (*
  5.    Produce a formatted NxN multiplication table
  6.    Only print the top half triangle of products
  7. *)
  8.  
  9. MODULE MultiplicationTables;
  10.  
  11. IMPORT In, Out, Console;
  12.  
  13.  
  14. CONST
  15.     N = 18;
  16.  
  17.  
  18. VAR
  19.     I, J: INTEGER;
  20.  
  21.  
  22. BEGIN
  23.     Console.open;
  24.  
  25.     FOR J := 1 TO N - 1 DO
  26.         Out.Int(J, 3);
  27.         Out.String(" ")
  28.     END;
  29.     Out.Int(N, 3);
  30.     Out.Ln;
  31.     FOR J := 0 TO N - 1 DO
  32.         Out.String("----")
  33.     END;
  34.     Out.String("+");
  35.     Out.Ln;
  36.     FOR I := 1 TO N DO
  37.         FOR J := 1 TO N DO
  38.             IF J < I THEN
  39.                 Out.String("    ")
  40.             ELSE
  41.                 Out.Int(I * J, 3);
  42.                 Out.String(" ")
  43.             END
  44.         END;
  45.         Out.String("| ");
  46.         Out.Int(I, 2);
  47.         Out.Ln
  48.     END;
  49.     In.Ln;
  50.  
  51.     Console.exit(TRUE)
  52. END MultiplicationTables.