用C语言求n的阶乘
#include"stdio.h"double fac(int n){ if(n==0||n==1) return 1; else return n*fac(n-1);}void main(){ int b; double a; printf("请输入n的值:\n"); scanf("%d",&b); a=fac(b); printf("a=%.0lf\n",a);}
赞 (0)
#include"stdio.h"double fac(int n){ if(n==0||n==1) return 1; else return n*fac(n-1);}void main(){ int b; double a; printf("请输入n的值:\n"); scanf("%d",&b); a=fac(b); printf("a=%.0lf\n",a);}