Mosaic matrix: Difference between revisions
Content added Content deleted
(Added "see also") |
(Added Action!) |
||
Line 40: | Line 40: | ||
0 1 0 1 0 1 0 1 0 |
0 1 0 1 0 1 0 1 0 |
||
1 0 1 0 1 0 1 0 1 |
1 0 1 0 1 0 1 0 1 |
||
</pre> |
|||
=={{header|Action!}}== |
|||
<syntaxhighlight lang="action!"> |
|||
;;; draw a "mosaic matrix" - one with a 1 in the top-left and then |
|||
;;; alternating with another character vertically and horiontally |
|||
;;; draws a mosaic matrix with height and width = n |
|||
PROC drawMosaic( INT n ) |
|||
CARD i, j, one |
|||
FOR i = 1 TO n DO |
|||
one = i AND 1 |
|||
FOR j = 1 TO n DO |
|||
Put(' ) |
|||
IF one = 1 THEN Put('1) ELSE Put('.) FI |
|||
one = ( one + 1 ) AND 1 |
|||
OD |
|||
PutE() |
|||
OD |
|||
RETURN |
|||
PROC Main() |
|||
drawMosaic( 6 ) |
|||
PutE() |
|||
drawMosaic( 7 ) |
|||
RETURN |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
1 . 1 . 1 . |
|||
. 1 . 1 . 1 |
|||
1 . 1 . 1 . |
|||
. 1 . 1 . 1 |
|||
1 . 1 . 1 . |
|||
. 1 . 1 . 1 |
|||
1 . 1 . 1 . 1 |
|||
. 1 . 1 . 1 . |
|||
1 . 1 . 1 . 1 |
|||
. 1 . 1 . 1 . |
|||
1 . 1 . 1 . 1 |
|||
. 1 . 1 . 1 . |
|||
1 . 1 . 1 . 1 |
|||
</pre> |
</pre> |
||