Minimum number of cells after, before, above and below NxN squares: Difference between revisions

add FreeBASIC
(add FreeBASIC)
Line 641:
 
0
</pre>
 
=={{header|FreeBASIC}}==
<lang freebasic>#define min(a, b) Iif(a<=b,a,b)
 
sub minab( n as uinteger )
for i as uinteger = 1 to n
for j as uinteger = 1 to n
print using "## ";min( min(i-1, n-i), min(j-1, n-j) );
next j
print
next i
end sub
 
minab(10)</lang>
{{out}}<pre>
0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 1 0
0 1 2 2 2 2 2 2 1 0
0 1 2 3 3 3 3 2 1 0
0 1 2 3 4 4 3 2 1 0
0 1 2 3 4 4 3 2 1 0
0 1 2 3 3 3 3 2 1 0
0 1 2 2 2 2 2 2 1 0
0 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0
</pre>
 
781

edits