Last active
December 26, 2015 20:09
-
-
Save euank/7206859 to your computer and use it in GitHub Desktop.
fizzbuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
struct node { | |
struct node *next; | |
char *str; | |
}; | |
int main (void) { | |
struct node nodes[0xF]; | |
int i; | |
for (i=0;i<0xF;++i) { | |
nodes[i].next = &nodes[(i+1)%0xF]; | |
nodes[i].str = strdup("%d"); | |
} | |
for(i=0;i<0xF;i+=0b11) nodes[i].str = strdup(" \bfizz"); | |
for(i=0;i<0xF;i+=0b101) nodes[i].str = strcat(nodes[i].str+2, strdup("buzz")); | |
struct node * cur = &nodes[0]; | |
for (i = 1; i < 0144; ++i) { | |
cur = cur->next; | |
printf(cur->str, i); | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment