0
|
1 #include "stdio.h"
|
|
2
|
|
3 int
|
|
4 main(ac,av)
|
|
5 int ac;
|
|
6 char *av[];
|
|
7 {
|
|
8 int n;
|
|
9 n = atoi(av[1]);
|
|
10 goto factorial(n,1,n,print,return,environment);
|
|
11 }
|
|
12
|
|
13 code print(n,result,orig,print,exit1,exit1env)
|
|
14 int n,result,orig;
|
|
15 code (*print)(),(*exit1)();
|
|
16 void *exit1env;
|
|
17 {
|
|
18 printf("%d! = %d\n",n, result);
|
|
19 goto (*exit1)(1),exit1env;
|
|
20 }
|
|
21
|
|
22 code factorial(n,result,orig,print,exit1,exit1env)
|
|
23 int n,result,orig;
|
|
24 code (*print)();
|
|
25 code (*exit1)();
|
|
26 void *exit1env;
|
|
27 {
|
|
28 if (n<0) {
|
|
29 printf("err %d!\n",n);
|
|
30 goto (*exit1)(0),exit1env;
|
|
31 }
|
|
32 if (n==0)
|
7
|
33 goto (*print)(n,result,orig,print,exit1,exit1env);
|
|
34 /* goto print(n,result,orig,print,exit1,exit1env); */
|
0
|
35 else {
|
|
36 result *= n;
|
|
37 n--;
|
|
38 goto factorial(n,result,orig,print,exit1,exit1env);
|
|
39 }
|
|
40 }
|