Created
September 13, 2017 21:30
-
-
Save waltman/354d043fe13271c87bd4389e709ddf53 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
#include <stdio.h> | |
int main() { | |
int fizzbuzz[101]; | |
for (int i = 1; i <= 100; i++) | |
fizzbuzz[i] = 0; | |
for (int i = 3; i <= 100; i += 3) | |
fizzbuzz[i] = 1; | |
for (int i = 5; i <= 100; i += 5) | |
fizzbuzz[i] = 2; | |
for (int i = 15; i <= 100; i += 15) | |
fizzbuzz[i] = 3; | |
for (int i = 1; i <= 100; i++) | |
switch (fizzbuzz[i]) { | |
case 0: printf("%d\n", i); break; | |
case 1: puts("fizz"); break; | |
case 2: puts("buzz"); break; | |
case 3: puts("fizzbuzz"); break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment