hduoj2018(母牛的故事)

来源:互联网 发布:python 中文注释 编辑:程序博客网 时间:2024/05/01 07:43

题意:http://acm.hdu.edu.cn/showproblem.php?pid=2018

解答:

#include<stdio.h>

int cow(int a)

{

         if(a<5)return a;

         else return cow(a-1)+cow(a-3);

}

int main()

{

int a;

while(scanf("%d",&a),a) 

printf("%d\n",cow(a));

return 0;

}

0 0
原创粉丝点击