Created
February 14, 2017 03:19
-
-
Save lancetw/6f87d2969ad2e2e4774aeefba5820f47 to your computer and use it in GitHub Desktop.
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
char** fizzBuzz(int n, int* returnSize) { | |
char** ret = calloc(n, sizeof(char*)); | |
*returnSize = n; | |
char* sp; | |
for (int i = 1; i <= n; ++i) { | |
sp = *(ret + (i - 1)) = calloc(1, sizeof(char)); | |
(i % 5 && i % 3) ? sprintf(sp, "%d", i) : sprintf(sp, "%s%s", (i % 3) ? "" : "Fizz", (i % 5) ? "" : "Buzz"); | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment