C语言刷题(5):用static,计算阶乘
程序员文章站
2024-01-31 08:47:10
...
#include <stdio.h>
void main()
{
int fac(int n);
int i;
for(i = 1;i<=4;i++)
{
fac(i);
}
printf("5! =%d",fac(i));
}
int fac(int n)
{
static int f=1;
f = f * n;
return f;
}