Created
May 9, 2012 14:44
-
-
Save nerocrux/2645009 to your computer and use it in GitHub Desktop.
fizzbuzz without mod (c++)
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> | |
void fizzbuzz(int num_fizz, int num_buzz, int num_fizzbuzz, int counter) | |
{ | |
if(num_fizzbuzz == 15) {printf("fizzbuzz "); num_fizz=0; num_buzz=0; num_fizzbuzz=0;} | |
else if(num_fizz == 3) {printf("fizz "); num_fizz=0;} | |
else if(num_buzz == 5) {printf("buzz "); num_buzz=0;} | |
else printf("%d ", counter); | |
if (counter < 100) fizzbuzz(++num_fizz, ++num_buzz, ++num_fizzbuzz, ++counter); | |
} | |
main () | |
{ | |
fizzbuzz(1,1,1,1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment