Spiral matrix: Difference between revisions

m
No edit summary
Line 1,607:
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls, Windows}}
This code actually creates a the required matrix instead of simulating one. It can also create matriciesmatrices of any size and the matriciesmatrices don't have to be square. It works by creating a rectangle of the same size as the matrix, then entering the values along the lines of the rectangle. It then uses the Windows library routine "InflateRect" to decrease the size of the rectangle until the whole matrix is filled with spiraling values.
 
<syntaxhighlight lang="Delphi">
Line 1,673:
R:=Rect(0,0,SizeX-1,SizeY-1);
Inx:=0;
{draw and deflate rectanlerectangle until spiral is done}
while (R.Left<=R.Right) and (R.Top<=R.Bottom) do
begin
Line 1,732:
 
</pre>
 
 
=={{header|E}}==
465

edits