??? 06/08/04 14:42 Read: times |
#72077 - RE: Weekend Puzzle Responding to: ???'s previous message |
Even it is a puzzle, it must still be 100% free of syntactical and logical errors and should run on every C compiler all over the world.
But a code with the assumption that only the number "1" has the meaning "true", was wrong at all. So please write this: z = (a > b) ? 1 : 0; // z always only 0 or 1 instead this: z = a > b; // wrong for further numerical analysis ! Peter P.S.: I like the puzzle not, since its many times to awkward. Instead converting numbers to strings, manipulate it and convert it back, I'm sure it can also be done directly on the number on saving about 100 times of code and about 1000 times of CPU speed. So I have no time wasted with deeper analysis. Only the big logical error hit my eyes on a first view |