0
|
1 #include "stdio.h"
|
|
2
|
622
|
3 __code factorial(int n,int result,int orig,__code(*print)(),__code(*exit1)(), void *exit1env)
|
5
|
4 {
|
|
5 if (n<0) {
|
427
|
6 printf("#0005:err %d!\n",n);
|
5
|
7 goto (*exit1)(0),exit1env;
|
|
8 }
|
|
9 if (n==0)
|
|
10 goto (*print)(n,result,orig,print,exit1,exit1env);
|
|
11 else {
|
|
12 result *= n;
|
|
13 n--;
|
|
14 goto factorial(n,result,orig,print,exit1,exit1env);
|
|
15 }
|
|
16 }
|
|
17
|
622
|
18 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env);
|
572
|
19
|
0
|
20 int main( int ac, char *av[])
|
|
21 {
|
|
22 int n;
|
172
|
23 // n = atoi(av[1]);
|
|
24 n = 10;
|
720
|
25 goto factorial(n,1,n,print,__return,__environment);
|
0
|
26 }
|
|
27
|
622
|
28 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env)
|
0
|
29 {
|
573
|
30 printf("#0029:%d! = %d\n",orig, result);
|
172
|
31 goto (*exit1)(0),exit1env;
|
0
|
32 }
|
|
33
|