Jump to content

Mosaic matrix: Difference between revisions

(Added 11l)
Line 95:
 
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">BEGIN # draw a "mosaic matrix" - one with a 1 in the top-left and then #
BEGIN # draw a "mosaic matrix" - one with a 1 in the top-left and then #
# alternating with another character vertically and horiontally #
# horiontally #
# draws a mosaic matrix with height and width = n using "1" and "." #
PROC draw mosaic = ( INT n )VOID:
BEGINFOR i TO n DO
CHAR set BOOL one := "1"ODD i;
CHAR resetFOR =j ".";TO n DO
FOR i TO n DO print( ( " ", IF one THEN "1" ELSE "." FI ) );
CHAR cone := IFNOT ODD i THEN set ELSE reset FI;one
FOR j TO n DOOD;
print( ( " ", cnewline ) );
ENDOD # draw mosaic # ;
c := IF c = set THEN reset ELSE set FI
OD;
print( ( newline ) )
OD
END # draw mosaic # ;
# test the draw mosaic procedure #
draw mosaic( 10 );
print( ( newline ) );
draw mosaic( 11 )
END
END</syntaxhighlight>
{{out}}
<pre>
Line 141 ⟶ 140:
1 . 1 . 1 . 1 . 1 . 1
</pre>
 
=={{header|Arturo}}==
 
3,038

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.