也就是 1 1 1 2 3 4 6 9.........
1 1 1 2 3 4 6 9.......
因为以后4年后每往后1年就有4年前出生的牛能够生育....
[此贴子已经被作者于2007-6-14 9:43:47编辑过]
int a[20]={1,1,1},i=0;
for(i>3;i<13;i++)
a[i]=a[i-1]+a[i-3];
a[12]就是要求的``60
我功底不行 看不懂复杂的 只会写这种~~~~~!
You catch the main step of a good algorithm. Though you may not wrote the right code, however, what you thought is really good.
See the code on 3 floor, he has made the perfect program for that algorithm!
1. This problem is really a math problem. Do you agree?
2. There are some good C++/C coding style "standards" out there. I personally used some source code beautifier: say sourceFormatX (this program is very very very risky --- it may delete your windows registry if you use the shareware version!!! Google sourceFormatX and 看雪 for it), greatcode (open source @ sourceforge, and my own simple beautifier written in C++.
Best of the luck!