fork download
  1. #include <stdio.h>
  2. //発展課題4
  3. int trb(int n)
  4. {
  5. if(n==0)
  6. return 0;
  7. else if(n==1)
  8. return 0;
  9. else if(n==2)
  10. return 1;
  11. else return trb(n-1)+trb(n-2)+trb(n-3);
  12. }
  13.  
  14. int main(void)
  15. {
  16. int n;
  17.  
  18. scanf("%d",&n);
  19. printf("%d\n",trb(n));
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5288KB
stdin
5
stdout
4