13
|
1 #include<stdio.h>
|
|
2 #define code __code
|
|
3 #define __return _CbC_return
|
|
4 typedef code (*NEXT)(int,void*);
|
|
5
|
|
6 int main(int argc, char **argv) ;
|
|
7 int factor(int x) ;
|
|
8 code factor0(int prod,int x,NEXT next) ;
|
|
9 code print_fact(int value) ;
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14 int main(int argc, char **argv) {
|
|
15 int i,a;
|
|
16 i = atoi(argv[1]);
|
|
17 a = factor(i);
|
|
18 printf("%d! = %d\n", a);
|
|
19 }
|
|
20 int factor(int x) {
|
|
21 goto factor0(1, x, __return);
|
|
22 }
|
|
23 code factor0(int prod,int x,NEXT next) {
|
|
24 if (x >= 1) {
|
|
25 goto factor0(prod*x, x-1, next);
|
|
26 } else {
|
|
27 goto (*next)(prod,NULL);
|
|
28 }
|
|
29 }
|