Department numbers: Difference between revisions
Content deleted Content added
→{{header|TypeScript}}: Added. |
Department numbers in various BASIC dialents (BASIC256, PureBasic, Run BASIC and Yabasic) |
||
Line 829:
6 4 2
6 5 1</pre>
=={{header|BASIC}}==
==={{header|BASIC256}}===
<lang BASIC256>print "--police-- --sanitation-- --fire--"
for police = 2 to 7 step 2
for fire = 1 to 7
if fire = police then continue for
sanitation = 12 - police - fire
if sanitation = fire or sanitation = police then continue for
if sanitation >= 1 and sanitation <= 7 then
print rjust(police, 6); rjust(fire, 13); rjust(sanitation, 12)
end if
next fire
next police</lang>
{{out}}
<pre>--police-- --sanitation-- --fire--
2 3 7
2 4 6
2 6 4
2 7 3
4 1 7
4 2 6
4 3 5
4 5 3
4 6 2
4 7 1
6 1 5
6 2 4
6 4 2
6 5 1</pre>
==={{header|Run BASIC}}===
<lang runbasic>print "police fire sanitation"
for police = 2 to 7 step 2
for fire = 1 to 7
if fire = police then [cont]
sanitation = (12-police)-fire
if sanitation <= 0 or sanitation > 7 or sanitation = fire or sanitation = police then [cont]
print " "; police; chr$(9); fire; chr$(9); sanitation
[cont]
next fire
next police</lang>
==={{header|PureBasic}}===
<lang PureBasic>OpenConsole()
PrintN("--police-- --sanitation-- --fire--")
For police = 2 To 7 Step 2
For fire = 1 To 7
If fire = police:
Continue
EndIf
sanitation = 12 - police - fire
If sanitation = fire Or sanitation = police: Continue : EndIf
If sanitation >= 1 And sanitation <= 7:
PrintN(" " + Str(police) + #TAB$ + #TAB$ + Str(fire) + #TAB$ + #TAB$ + Str(sanitation))
EndIf
Next fire
Next police
Input()
CloseConsole()</lang>
{{out}}
<pre>Same as BASIC256 entry.</pre>
==={{header|Yabasic}}===
<lang freebasic>print "--police-- --sanitation-- --fire--"
for police = 2 to 7 step 2
for fire = 1 to 7
if fire = police continue
sanitation = 12 - police - fire
if sanitation = fire or sanitation = police continue
if sanitation >= 1 and sanitation <= 7 print police using "######", fire using "############", sanitation using "###########"
next fire
next police</lang>
{{out}}
<pre>Same as BASIC256 entry.</pre>
==={{header|IS-BASIC}}===
<lang IS-BASIC>100 PRINT "Police","San.","Fire"
|