#include <stdio.h> #define NEXT 0 #define FIZZ 1 #define BUZZ 2 #define FIZZ_BUZZ 3 #define PASS 4 int main(void){ int i, state; state = NEXT; for(i = 0; i <= 100; i++){ if(i % 3 == 0){ state = FIZZ; } if(i % 5 == 0){ state = BUZZ; } if(!(FIZZ || BUZZ)) state = PASS; if((state == FIZZ && (i % 5 == 0)) || (state == BUZZ && (i % 3 ==0))){ state = FIZZ_BUZZ; } switch(state){ case FIZZ: state = NEXT; break; case BUZZ: state = NEXT; break; case FIZZ_BUZZ: state = NEXT; break; default: break; } } }
Standard input is empty
0, FIZZ BUZZ 3, FIZZ 5, BUZZ 6, FIZZ 9, FIZZ 10, BUZZ 12, FIZZ 15, FIZZ BUZZ 18, FIZZ 20, BUZZ 21, FIZZ 24, FIZZ 25, BUZZ 27, FIZZ 30, FIZZ BUZZ 33, FIZZ 35, BUZZ 36, FIZZ 39, FIZZ 40, BUZZ 42, FIZZ 45, FIZZ BUZZ 48, FIZZ 50, BUZZ 51, FIZZ 54, FIZZ 55, BUZZ 57, FIZZ 60, FIZZ BUZZ 63, FIZZ 65, BUZZ 66, FIZZ 69, FIZZ 70, BUZZ 72, FIZZ 75, FIZZ BUZZ 78, FIZZ 80, BUZZ 81, FIZZ 84, FIZZ 85, BUZZ 87, FIZZ 90, FIZZ BUZZ 93, FIZZ 95, BUZZ 96, FIZZ 99, FIZZ 100, BUZZ