Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define __environment _CbC_environment
- #define __return _CbC_return
- #include <stdio.h>
- typedef __code(*main_ret_code_t)(int, void *env);
- __code fizzbuzz(int n, int max, main_ret_code_t ret, void *env);
- __code fizz(int n, int max, main_ret_code_t ret, void *env);
- __code buzz(int n, int max, const char *fizz, main_ret_code_t ret, void *env);
- __code print_fizzbuzz(int n, int max, const char *fizz, const char *buzz, main_ret_code_t ret, void *env);
- int main(void){
- goto fizzbuzz(1, 100, __return, __environment);
- }
- __code fizzbuzz(int n, int max, main_ret_code_t ret, void *env) {
- if (n > max) goto ret(0, env);
- goto fizz(n, max, ret, env);
- }
- __code fizz(int n, int max, main_ret_code_t ret, void *env) {
- if (n % 3 == 0) {
- goto buzz(n, max, "Fizz", ret, env);
- } else {
- goto buzz(n, max, "", ret, env);
- }
- }
- __code buzz(int n, int max, const char *fizz, main_ret_code_t ret, void *env) {
- if (n % 5 == 0) {
- goto print_fizzbuzz(n, max, fizz, "Buzz", ret, env);
- } else {
- goto print_fizzbuzz(n, max, fizz, "", ret, env);
- }
- }
- __code print_fizzbuzz(int n, int max, const char *fizz, const char *buzz, main_ret_code_t ret, void *env) {
- if (*fizz || *buzz) {
- printf("%s%s\n", fizz, buzz);
- } else {
- printf("%d\n", n);
- }
- goto fizzbuzz(n + 1, max, ret, env);
- }
Add Comment
Please, Sign In to add comment