Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- static const char *vals[] = {
- NULL, NULL, "Fizz", NULL, "Buzz", "Fizz", NULL, NULL,
- "Fizz", "Buzz", NULL, "Fizz", NULL, NULL, "FizzBuzz"
- };
- static void fizzbuzz(int n)
- {
- for (int i = 0; i < n; i++)
- if (vals[i % 15])
- puts(vals[i % 15]);
- else
- printf("%d\n", i + 1);
- }
- int main(int argc, char *argv[])
- {
- if (argc < 2)
- return 1;
- fizzbuzz(atoi(argv[1]));
- return 0;
- }
Add Comment
Please, Sign In to add comment