Decision tables: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed size of the output window.) |
(add FreeBASIC) |
||
Line 717: | Line 717: | ||
So, you don't have a problem then?</pre> |
So, you don't have a problem then?</pre> |
||
Keyboard handling is sketchy, just type "true" or "false" to each question. |
|||
=={{header|FreeBASIC}}== |
|||
<lang freebasic>dim as boolean rules(0 to 2, 0 to 7) =_ |
|||
{ {false, false, false, false, true, true, true, true},_ |
|||
{ true, true, false, false, true, true, false, false},_ |
|||
{false, true, false, true, false, true, false, true} } |
|||
dim as boolean actions(0 to 4, 0 to 7) =_ |
|||
{ {false, false, true, false, false, false, false, false},_ |
|||
{ true, false, true, false, false, false, false, false},_ |
|||
{ true, false, true, false, true, false, true, false},_ |
|||
{ true, true, false, false, false, true, false, false},_ |
|||
{false, true, false, true, false, false, false, false} } |
|||
dim as string rule_names(0 to 2) =_ |
|||
{"Printer prints", "A red light is flashing",_ |
|||
"Printer is recognized by computer"} |
|||
dim as string action_names(0 to 4) = _ |
|||
{"Check the power cable", "Check the printer-computer cable",_ |
|||
"Ensure printer software is installed", "Check/replace ink",_ |
|||
"Check for paper jam" } |
|||
dim as boolean answers(0 to 2) |
|||
for i as uinteger = 0 to 2 |
|||
print rule_names(i), |
|||
input answers(i) |
|||
next i |
|||
print "---- Suggested solutions: ----" |
|||
for i as uinteger = 0 to 4 |
|||
for j as uinteger = 0 to 7 |
|||
if not actions(i, j) then continue for |
|||
for k as uinteger = 0 to 2 |
|||
if rules(k, j)<>answers(j) then goto dontdoit |
|||
next k |
|||
print action_names(i) |
|||
dontdoit: |
|||
next j |
|||
next i</lang> |
|||
=={{header|Go}}== |
=={{header|Go}}== |