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

Content added Content deleted
m (→‎{{header|Haskell}}: Dropped Data.Bool)
Line 507: Line 507:
<pre>
<pre>
Igual que la entrada de FreeBASIC.
Igual que la entrada de FreeBASIC.
</pre>

==={{header|RapidQ}}===
{{trans|FreeBASIC}}
Introduced extra variables <code>MinI</code> and <code>MinJ</code>, because nested <code>Min</code> functions do not work correctly (why do they not?).
<syntaxhighlight lang="xbasic">
' Minimum number of cells after, before, above and below NxN squares
DECLARE FUNCTION Min(A AS WORD, B AS WORD) AS WORD
DECLARE SUB MinAB(N AS WORD)

CLS
MinAB(10)
END

FUNCTION Min(A AS WORD, B AS WORD) AS WORD
IF A <= B THEN Min = A ELSE Min = B
END FUNCTION

SUB MinAB(N AS WORD)
FOR I = 1 TO N
MinI = Min(I - 1, N - I)
FOR J = 1 TO N
MinJ = Min(J - 1, N - J)
PRINT FORMAT$("%2d ", Min(MinI, MinJ));
NEXT J
PRINT
NEXT I
END SUB
</syntaxhighlight>
{{out}}
To samo, co we FreeBASIC.
<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>
</pre>