Mercurial > hg > CbC > old > device
view test/fact.c @ 16:ca0bce3b4810
struct copy
author | kono |
---|---|
date | Mon, 17 Jan 2000 16:08:16 +0900 |
parents | e2c2c0fe0785 |
children | 096559f07a70 |
line wrap: on
line source
#include "stdio.h" int main(ac,av) int ac; char *av[]; { int n; n = atoi(av[1]); goto factorial(n,1,n,print,return,environment); } code print(n,result,orig,print,exit1,exit1env) int n,result,orig; code (*print)(),(*exit1)(); void *exit1env; { printf("%d! = %d\n",n, result); goto (*exit1)(1),exit1env; } code factorial(n,result,orig,print,exit1,exit1env) int n,result,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); /* goto print(n,result,orig,print,exit1,exit1env); */ else { result *= n; n--; goto factorial(n,result,orig,print,exit1,exit1env); } }