Mercurial > hg > CbC > old > device
view test/fact-a.c @ 647:fe23fe842b82
*** empty log message ***
author | kono |
---|---|
date | Fri, 17 Nov 2006 20:00:37 +0900 |
parents | 682c8ec38d45 |
children | 6b7372e17970 |
line wrap: on
line source
#include "stdio.h" __code factorial(int n,int result,int orig,__code(*print)(),__code(*exit1)(), void *exit1env) { if (n<0) { printf("#0005: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); } } __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env); int main( int ac, char *av[]) { int n; // n = atoi(av[1]); n = 10; goto factorial(n,1,n,print,return,environment); } __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env) { printf("#0029:%d! = %d\n",orig, result); goto (*exit1)(0),exit1env; }