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 13:40, 6 December 2021
, 2 years agoMinimum number of cells after, before, above and below NxN squares in various BASIC dialents
Catskill549 (talk | contribs) (added AWK) |
(Minimum number of cells after, before, above and below NxN squares in various BASIC dialents) |
||
Line 283:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
</pre>
=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<lang BASIC256>function min(a, b)
if a<=b then return a else return b
end function
subroutine minab(n)
for i = 1 to n
for j = 1 to n
print min(min(i-1, n-i), min(j-1, n-j)); " ";
next j
print
next i
end subroutine
call minab(10)
end</lang>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
==={{header|QBasic}}===
{{works with|QBasic}}
{{works with|QuickBasic}}
{{trans|FreeBASIC}}
<lang QBasic>DECLARE FUNCTION min! (a!, b!)
DECLARE SUB minab (n!)
CLS
minab (10)
END
FUNCTION min (a, b)
IF a <= b THEN min = a ELSE min = b
END FUNCTION
SUB minab (n)
FOR i = 1 TO n
FOR j = 1 TO n
PRINT USING "## "; min(min(i - 1, n - i), min(j - 1, n - j));
NEXT j
PRINT
NEXT i
END SUB</lang>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
==={{header|True BASIC}}===
{{trans|QBasic}}
<lang qbasic>FUNCTION min (a, b)
IF a <= b THEN LET min = a ELSE LET min = b
END FUNCTION
SUB minab (n)
FOR i = 1 TO n
FOR j = 1 TO n
PRINT USING "## ": min(min(i - 1, n - i), min(j - 1, n - j));
NEXT j
PRINT
NEXT i
END SUB
CALL minab (10)
END</lang>
{{out}}
<pre>
Igual que la entrada de QBasic.
</pre>
==={{header|Yabasic}}===
{{trans|FreeBASIC}}
<lang yabasic>minab(10)
end
sub minab(n)
for i = 1 to n
for j = 1 to n
print min(min(i-1, n-i), min(j-1, n-j)) using ("##");
next j
print
next i
end sub</lang>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
=={{header|BCPL}}==
|