#include<stdio.h>
unsigned long f(int n)
{
unsigned long k;
if(n==0) k=0;
else if(n==1) k=1;
else if(n==2) k=2;
else
k=2*f(n-1)+f(n-2)*f(n-3);
return k;
}
int main()
{
int n;
unsigned long y;
printf("INPUT n(2<=n<=13):");
scanf("%d",&n);
printf("\n");
y=f(n);
printf("f(%d)=%d\n",n,y);
return 0;
}
才疏,12和13有溢出,处理不了,编译器不一样,int的字节也不一样,参考3楼
unsigned long f(int n)
{
unsigned long k;
if(n==0) k=0;
else if(n==1) k=1;
else if(n==2) k=2;
else
k=2*f(n-1)+f(n-2)*f(n-3);
return k;
}
int main()
{
int n;
unsigned long y;
printf("INPUT n(2<=n<=13):");
scanf("%d",&n);
printf("\n");
y=f(n);
printf("f(%d)=%d\n",n,y);
return 0;
}
才疏,12和13有溢出,处理不了,编译器不一样,int的字节也不一样,参考3楼