06-24-2003, 06:32 AM
Code:
Ok, here's the rules:
1) It must be considered an algorithm, formula or method.
Add 15 to X ---- X=X+15 This is not an algorithm, agreed?
If it were, then every line of code in a program would be.
2) You must describe the algorithm first, i.e., what is its purpose.
3) Then show the one line of code.
4) Multiple statments on one line; like: x=x+1 : x=x and 15
are not considered as one line of code.
A good example is one we've already seen with the XOR.
The purpose is to turn a switch on if it's off, and turn it off if it's on.
The one line of code is: sw=sw xor sw
or equally cool: sw=1-sw