设有一头小母牛,从出生第四年起每年生一头小母牛,按此规律,第N年时有几头母牛?

#include<stdio.h>

int f(int N)
{
  if (N < 4)
  return 1;
  else
  return f(N - 1) + f(N- 3);
}
int main()
{
  int N;
  scanf("%d", &N);
  printf("%d",f(N));
}

猜你喜欢

转载自www.cnblogs.com/minghaomaopao/p/10123143.html