Four sides of square: Difference between revisions

Added Action!
(Added Algol W)
(Added Action!)
Line 37:
1 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1
</pre>
 
=={{header|Action!}}==
<syntaxhighlight lang="action!">
;;; draw a matrix with 1s on the edges and 0s elsewhere
 
;;; draws a matrix with height and width = n with 1s on the edges
PROC drawSquare( INT n )
CARD i, j
FOR i = 1 TO n DO
FOR j = 1 TO n DO
Put(' )
IF i = 1 OR i = n OR j = 1 OR j = n THEN Put('1) ELSE Put('0) FI
OD
PutE()
OD
RETURN
 
PROC Main()
drawSquare( 6 )
PutE()
drawSquare( 7 )
RETURN
</syntaxhighlight>
{{out}}
<pre>
1 1 1 1 1 1
1 0 0 0 0 1
1 0 0 0 0 1
1 0 0 0 0 1
1 0 0 0 0 1
1 1 1 1 1 1
 
1 1 1 1 1 1 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 1 1 1 1 1 1
</pre>
 
3,021

edits