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

fizz buzz

Name: Anonymous 2011-10-15 16:47

I have achieved my lifelong dream. Finally a fizz buzz program with 0 comparison operator.

#include <stdio.h>
#include <stdlib.h>

void main(int j){
  const char* s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
  printf(s[3-!!(j%3)-2*!!(j%5)], j);
  (main+((exit-main)*(j/100)))((1-j/100)*j+1);
}

Name: Anonymous 2011-10-15 18:23

See:

http://codepad.org/T1grqp7Z

Final code:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uintptr_t p;
char *s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
int e(int i, char **j) {
    int k;
    char **l;
    k = i;
    l = j;
    exit(0);
}
int main(int i, char **j) {
    char **k;
    k = j;
    printf(s
[(!(i % 3)) | ((!(i % 5)) << 1)], i);
    (*((int (*)(int, char **))((p)(main) + ((p)(e) -
    (p)(main)) * (i / 100))))(i + 1, NULL);
    return 0;
}


Compiles, warning-free, with:

gcc -ansi -Wall -Werror -Wextra -pedantic

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