Four sides of square: Difference between revisions

Added Algol W
(Added "See also")
(Added Algol W)
Line 127:
1 1 1 1 1 1 1
</pre>
 
=={{header|ALGOL W}}==
<syntaxhighlight lang="algolw">
begin % draw a matrix with 1s on the edges and 0s elsewhere %
% draws a matrix with height and width = n with 1s on the edges %
procedure drawSquare ( integer value n ) ;
for i := 1 until n do begin
for j := 1 until n do begin
writeon( s_w := 0, if i = 1 or i = n or j = 1 or j = n then " 1" else " 0" )
end for_j ;
write()
end drawSquare ;
% test the draw square procedure %
drawSquare( 6 );
write();
drawSquare( 7 )
end.
</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>
 
=={{header|AppleScript}}==
Defined in terms of a generic matrix function:
3,032

edits