若一头小母牛,从出生起第四个年头开始每年生一头母牛,按此规律,第n年时有多少头母牛?
#include<stdio.h>#include<conio.h>
int fun(int);
int main()
{
int n;
printf("Please input the year(s):");
scanf("%d",&n);
printf("the total %s %d",n>3?"are":"is",fun(n));
getch();
return 0;
}
int fun(int years)
{
return (years<4?1:2*fun(years-4));
}
我做出来无解啊 求高人