Minimum number of cells after, before, above and below NxN squares: Difference between revisions
Minimum number of cells after, before, above and below NxN squares (view source)
Revision as of 10:43, 15 November 2021
, 2 years agoadd FreeBASIC
(→{{header|Ruby}}: Add ruby) |
(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>
|