daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest May 16th, 2018 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define __environment _CbC_environment
  2. #define __return _CbC_return
  3.  
  4. #include <stdio.h>
  5.  
  6. typedef __code(*main_ret_code_t)(int, void *env);
  7.  
  8. __code fizzbuzz(int n, int max, main_ret_code_t ret, void *env);
  9. __code fizz(int n, int max, main_ret_code_t ret, void *env);
  10. __code buzz(int n, int max, const char *fizz, main_ret_code_t ret, void *env);
  11. __code print_fizzbuzz(int n, int max, const char *fizz, const char *buzz, main_ret_code_t ret, void *env);
  12.  
  13. int main(void){
  14.   goto fizzbuzz(1, 100, __return, __environment);
  15. }
  16.  
  17. __code fizzbuzz(int n, int max, main_ret_code_t ret, void *env) {
  18.   if (n > max) goto ret(0, env);
  19.  
  20.   goto fizz(n, max, ret, env);
  21. }
  22.  
  23. __code fizz(int n, int max, main_ret_code_t ret, void *env) {
  24.   if (n % 3 == 0) {
  25.     goto buzz(n, max, "Fizz", ret, env);
  26.   } else {
  27.     goto buzz(n, max, "", ret, env);
  28.   }
  29. }
  30.  
  31. __code buzz(int n, int max, const char *fizz, main_ret_code_t ret, void *env) {
  32.   if (n % 5 == 0) {
  33.     goto print_fizzbuzz(n, max, fizz, "Buzz", ret, env);
  34.   } else {
  35.     goto print_fizzbuzz(n, max, fizz, "", ret, env);
  36.   }
  37. }
  38.  
  39. __code print_fizzbuzz(int n, int max, const char *fizz, const char *buzz, main_ret_code_t ret, void *env) {
  40.   if (*fizz || *buzz) {
  41.     printf("%s%s\n", fizz, buzz);
  42.   } else {
  43.     printf("%d\n", n);
  44.   }
  45.  
  46.   goto fizzbuzz(n + 1, max, ret, env);
  47. }
RAW Paste Data
Top