annotate test/fact-a.c @ 172:096559f07a70

some check
author kono
date Tue, 25 Nov 2003 11:47:41 +0900
parents 64a4e3789fd2
children 0c256ea2a97e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1 #include "stdio.h"
d35df41eac69 Initial revision
kono
parents:
diff changeset
2
5
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
3 code factorial(int n,int result,int orig,code(*print)(),code(*exit1)(), void *exit1env)
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
4 {
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
5 if (n<0) {
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
6 printf("err %d!\n",n);
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
7 goto (*exit1)(0),exit1env;
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
8 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
9 if (n==0)
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
10 goto (*print)(n,result,orig,print,exit1,exit1env);
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
11 else {
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
12 result *= n;
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
13 n--;
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
14 goto factorial(n,result,orig,print,exit1,exit1env);
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
15 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
16 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
17
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
18 int main( int ac, char *av[])
d35df41eac69 Initial revision
kono
parents:
diff changeset
19 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
20 int n;
172
096559f07a70 some check
kono
parents: 53
diff changeset
21 // n = atoi(av[1]);
096559f07a70 some check
kono
parents: 53
diff changeset
22 n = 10;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
23 goto factorial(n,1,n,print,return,environment);
d35df41eac69 Initial revision
kono
parents:
diff changeset
24 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
25
d35df41eac69 Initial revision
kono
parents:
diff changeset
26 code print(int n,int result,int orig,code(*print)(),(*exit1)(),void*exit1env)
d35df41eac69 Initial revision
kono
parents:
diff changeset
27 {
53
64a4e3789fd2 parallel assign works.
kono
parents: 5
diff changeset
28 printf("%d! = %d\n",orig, result);
172
096559f07a70 some check
kono
parents: 53
diff changeset
29 goto (*exit1)(0),exit1env;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
30 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
31