int rfact(int n)
{
if (n==0) return 1;
else return n*rfact(n-1);
}
int cfact(int n)
{
int r=1;
while(n>0) r*=n--;
return r;
}
int main()
{
int (*fact)(int n), n;
char c;
scanf("%i %c",&n, &c);
if(c=='c') fact=cfact;
else fact=rfact;
printf("%i\n", fact(n));
return 0;
}
No comments:
Post a Comment