Mercurial > hg > CbC > old > device
diff test/fact-a.c @ 5:3db1b6d78412
*** empty log message ***
author | kono |
---|---|
date | Thu, 13 Jan 2000 12:07:28 +0900 |
parents | d35df41eac69 |
children | 64a4e3789fd2 |
line wrap: on
line diff
--- a/test/fact-a.c Thu Jan 13 11:10:10 2000 +0900 +++ b/test/fact-a.c Thu Jan 13 12:07:28 2000 +0900 @@ -1,5 +1,20 @@ #include "stdio.h" +code factorial(int n,int result,int orig,code(*print)(),code(*exit1)(), void *exit1env) +{ + if (n<0) { + printf("err %d!\n",n); + goto (*exit1)(0),exit1env; + } + if (n==0) + goto (*print)(n,result,orig,print,exit1,exit1env); + else { + result *= n; + n--; + goto factorial(n,result,orig,print,exit1,exit1env); + } +} + int main( int ac, char *av[]) { int n; @@ -13,18 +28,3 @@ goto (*exit1)(1),exit1env; } -code factorial(int n,int result,int orig,code(*print)(),code(*exit1)(), - void *exit1env) -{ - if (n<0) { - printf("err %d!\n",n); - goto (*exit1)(0),exit1env; - } - if (n==0) - goto (*print)(n,result,orig,print,exit1,exit1env); - else { - result *= n; - n--; - goto factorial(n,result,orig,print,exit1,exit1env); - } -}