"Decision Maker," in C
This concept predates the Web -- it may even give the Internet competition for age. A friend showed me a good online copy here. But here is a version of the same thing, written in Dr. Ron's sloppy C:
//
// This is a program used to debug your brain when writing code
// -- it was originally published in BASIC, but this is a C equivalent.
// The original was here: http://www.meowfishies.com/code/flowchart.f
// It could be made simpler with more functions, but I figured the
// essential structure was enough visible this way. -- RG, 08.2007
//
include
int main {
int i1, i2, i3, i4, i5;
printf ("Does the damn thing work? (enter 1 for yes, 0 for no)");
scanf ("%d", &i2);
if (i1 != 0) then {
printf ("Don't mess with it!!!");
} else {
printf ("Did you screw around with it? (enter 1 for yes, 0 for no)");
scanf ("%d", &i2);
if (i2 != 0) then {
printf ("You fricken idiot! Does anyone know? (enter 1 for yes, 0 for no)");
scanf ("%d", &i3);
if (i3 != 0) then {
printf ("You poor sod. Can you blame someone else? (enter 1 for yes, 0 for no)");
scanf ("%d", &i4);
if (i4 != 0) then { np (); } else { ys (); }
} else { ti (); np (); }
} else { hi (); np (); }
} else {
printf ("Will you be blamed for it? (enter 1 for yes, 0 for no)");
scanf ("%d", &i5);
if (i5 != 0) then {
printf ("You poor sod. Can you blame someone else? (enter 1 for yes, 0 for no)");
scanf ("%d", &i4);
if (i4 != 0) then { np (); } else { ys (); }
} else { ti (); np (); }
} else { hi (); np (); }
}
return 0;
} // end of main program
int np () { printf ("No problem! \n"); return 0; }
int ys () { printf ("You are so screwed! \n"); return 0; }
int hi () { printf ("Hide it! \n"); return 0; }
int ti () { printf ("Trash it! \n"); return 0; }
// end of functions
Labels: diversions





Site Feed





0 Comments:
Post a Comment
<< Home