Anonymous user
Multiplication tables: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace and comments, changed the 2nd output example.
m (→{{header|REXX}}: added/changed whitespace and comments, changed the 2nd output example.) |
|||
Line 2,895:
blc = '└' ; brc = '┘' /*bottom " " " " */
/* [↑] define stuff to hold box glyphs*/
cell = cj || copies(dash, 5) /*define the top of the cell.
sep = copies(cell, high+1)rj /*
width= length(cell)-1 /*width of the table cells. */
size = width-1 /*width for the
box. = left('', width) /*
do j=0 to high /*step through zero ───► high. */
_=right(j, size-1)'x ' /*build the "label" (border) number.
box.0.j=_ /*
box.j.0=_ /*
end /*j*/
box.0.0=centre('times', width) /*
do
do
box.
end /*
end /*
do
▲ if row==0 then do
end
▲ asep=translate(asep, tj ,cj) /*make a better tj. */
else @=overlay(lj, @ ,1)
say @
if r==0 then call buildLine 00 /* " " " blank grid " */
if r==0 then call buildLine 00 /*display a single blank grid line. */
@=sep
@=overlay(blc, @
@=overlay(brc, @ , L)
@=translate(@, bj, cj)
▲ end /*row*/
▲say asep /*display a table grid line. */
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
buildLine: parse
do col=0 to high /*step through zero ───► high. */
end
say $ || bar
▲say w || bar /*finish building the last cell. */
return</lang>
'''output''' when using the default input:
<pre>
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
Line 2,977 ⟶ 2,974:
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
</pre>
'''output''' when the following is used for input: <tt>
<pre>
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│times│ 1x │ 2x │ 3x │ 4x │ 5x │ 6x │ 7x │ 8x │ 9x │ 10x │ 11x │ 12x │ 13x │ 14x │ 15x │ 16x │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 1x │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12 │ 13 │ 14 │ 15 │ 16 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 2x │ │ 4 │ 6 │ 8 │ 10 │ 12 │ 14 │ 16 │ 18 │ 20 │ 22 │ 24 │ 26 │ 28 │ 30 │ 32 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 3x │ │ │ 9 │ 12 │ 15 │ 18 │ 21 │ 24 │ 27 │ 30 │ 33 │ 36 │ 39 │ 42 │ 45 │ 48 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 4x │ │ │ │ 16 │ 20 │ 24 │ 28 │ 32 │ 36 │ 40 │ 44 │ 48 │ 52 │ 56 │ 60 │ 64 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 5x │ │ │ │ │ 25 │ 30 │ 35 │ 40 │ 45 │ 50 │ 55 │ 60 │ 65 │ 70 │ 75 │ 80 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 6x │ │ │ │ │ │ 36 │ 42 │ 48 │ 54 │ 60 │ 66 │ 72 │ 78 │ 84 │ 90 │ 96 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 7x │ │ │ │ │ │ │ 49 │ 56 │ 63 │ 70 │ 77 │ 84 │ 91 │ 98 │ 105 │ 112 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 8x │ │ │ │ │ │ │ │ 64 │ 72 │ 80 │ 88 │ 96 │ 104 │ 112 │ 120 │ 128 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 9x │ │ │ │ │ │ │ │ │ 81 │ 90 │ 99 │ 108 │ 117 │ 126 │ 135 │ 144 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 10x │ │ │ │ │ │ │ │ │ │ 100 │ 110 │ 120 │ 130 │ 140 │ 150 │ 160 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 11x │ │ │ │ │ │ │ │ │ │ │ 121 │ 132 │ 143 │ 154 │ 165 │ 176 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 12x │ │ │ │ │ │ │ │ │ │ │ │ 144 │ 156 │ 168 │ 180 │ 192 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 13x │ │ │ │ │ │ │ │ │ │ │ │ │ 169 │ 182 │ 195 │ 208 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 14x │ │ │ │ │ │ │ │ │ │ │ │ │ │ 196 │ 210 │ 224 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 15x │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 225 │ 240 │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 16x │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 256 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
</pre>
|