Mosaic matrix: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
(→{{header|ALGOL 68}}: Simplify) |
||
Line 95: | Line 95: | ||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
<syntaxhighlight lang="algol68"> |
<syntaxhighlight lang="algol68"> |
||
BEGIN # draw a "mosaic matrix" - one with a 1 in the top-left and then # |
|||
# alternating with another character vertically and horiontally # |
# alternating with another character vertically and horiontally # |
||
# horiontally # |
|||
# draws a mosaic matrix with height and width = n using "1" and "." # |
# draws a mosaic matrix with height and width = n using "1" and "." # |
||
PROC draw mosaic = ( INT n )VOID: |
PROC draw mosaic = ( INT n )VOID: |
||
FOR i TO n DO |
|||
BOOL one := ODD i; |
|||
FOR j TO n DO |
|||
print( ( " ", IF one THEN "1" ELSE "." FI ) ); |
|||
one := NOT one |
|||
OD; |
|||
print( ( newline ) ) |
|||
⚫ | |||
c := IF c = set THEN reset ELSE set FI |
|||
OD; |
|||
print( ( newline ) ) |
|||
OD |
|||
⚫ | |||
# test the draw mosaic procedure # |
# test the draw mosaic procedure # |
||
draw mosaic( 10 ); |
draw mosaic( 10 ); |
||
print( ( newline ) ); |
print( ( newline ) ); |
||
draw mosaic( 11 ) |
draw mosaic( 11 ) |
||
END |
|||
</syntaxhighlight> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 141: | Line 140: | ||
1 . 1 . 1 . 1 . 1 . 1 |
1 . 1 . 1 . 1 . 1 . 1 |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||