Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

90% of /prog/ can't write FizzBuzz

Name: The antagonist 2008-04-25 12:38

Prove me wrong

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Name: Anonymous 2008-04-26 1:43

The fun thing about FizzBuzz (other than writing obfuscated versions) is to write versions that seem correct but aren't, present them to others and see if they spot the mistake.

#include <stdio.h>

int main() {
    int i, f, b;
    for(i=1;i<=100;i++) {
        if((f = !(i%3)) || (b = !(i%5)))
            printf("%s%s", f ? "Fizz" : "", b ? "Buzz" : "");
        else
            printf("%d", i);
        printf("\n");
    }
    return 0;
}


MD5 (solution) = 78a1dc71c6d126a040c7da4f006f717c

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List