Multiplication tables: Difference between revisions
Content added Content deleted
(removed superfluous "end") |
(Added solution for Action!) |
||
Line 407: | Line 407: | ||
11 11 22 33 44 55 66 77 88 99 110 121 |
11 11 22 33 44 55 66 77 88 99 110 121 |
||
12 12 24 36 48 60 72 84 96 108 120 132 144 |
12 12 24 36 48 60 72 84 96 108 120 132 144 |
||
</pre> |
|||
=={{header|Action!}}== |
|||
<lang Action!>PROC PrintRight(BYTE num,size) |
|||
BYTE i |
|||
IF num<10 THEN |
|||
size==-1 |
|||
ELSEIF num<100 THEN |
|||
size==-2 |
|||
ELSE |
|||
size==-3 |
|||
FI |
|||
FOR i=1 TO size |
|||
DO |
|||
Put(' ) |
|||
OD |
|||
PrintB(num) |
|||
RETURN |
|||
PROC Main() |
|||
BYTE ARRAY colw=[1 1 1 2 2 2 2 2 2 3 3 3] |
|||
BYTE i,j,x,w |
|||
;clear screen |
|||
Put(125) |
|||
;draw frame |
|||
Position(1,3) |
|||
FOR i=1 TO 38 |
|||
DO Put($12) OD |
|||
FOR j=2 TO 15 |
|||
DO |
|||
Position(36,j) |
|||
Put($7C) |
|||
OD |
|||
Position(36,3) |
|||
Put($13) |
|||
;draw numbers |
|||
FOR j=1 TO 12 |
|||
DO |
|||
x=1 |
|||
FOR i=1 TO 12 |
|||
DO |
|||
w=colw(i-1) |
|||
IF i>=j THEN |
|||
IF j=1 THEN |
|||
Position(x,j+1) |
|||
PrintRight(i*j,w) |
|||
FI |
|||
IF i=12 THEN |
|||
Position(37,j+3) |
|||
PrintRight(j,2) |
|||
FI |
|||
Position(x,j+3) |
|||
PrintRight(i*j,w) |
|||
FI |
|||
x==+w+1 |
|||
OD |
|||
OD |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Multiplication_tables.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
1 2 3 4 5 6 7 8 9 10 11 12│ |
|||
───────────────────────────────────┼── |
|||
1 2 3 4 5 6 7 8 9 10 11 12│ 1 |
|||
4 6 8 10 12 14 16 18 20 22 24│ 2 |
|||
9 12 15 18 21 24 27 30 33 36│ 3 |
|||
16 20 24 28 32 36 40 44 48│ 4 |
|||
25 30 35 40 45 50 55 60│ 5 |
|||
36 42 48 54 60 66 72│ 6 |
|||
49 56 63 70 77 84│ 7 |
|||
64 72 80 88 96│ 8 |
|||
81 90 99 108│ 9 |
|||
100 110 120│10 |
|||
121 132│11 |
|||
144│12 |
|||
</pre> |
</pre> |
||