Mosaic matrix: Difference between revisions

Content added Content deleted
(Added 11l)
Line 95: Line 95:


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">BEGIN # draw a "mosaic matrix" - one with a 1 in the top-left and then #
<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:
BEGIN
FOR i TO n DO
CHAR set = "1";
BOOL one := ODD i;
CHAR reset = ".";
FOR j TO n DO
FOR i TO n DO
print( ( " ", IF one THEN "1" ELSE "." FI ) );
CHAR c := IF ODD i THEN set ELSE reset FI;
one := NOT one
FOR j TO n DO
OD;
print( ( " ", c ) );
print( ( newline ) )
OD # draw mosaic # ;
c := IF c = set THEN reset ELSE set FI
OD;
print( ( newline ) )
OD
END # draw mosaic # ;
# 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
END</syntaxhighlight>
</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}}==