泡泡饭

导航

2009年10月30日 #

经典的农夫养牛问题

摘要: 一个农夫养了一头牛,三年后,这头牛每年会生出1头牛,生出来的牛三年后,又可以每年生出一头牛……问农夫10年后有多少头牛?n年呢?1.public class Cow { static int count = 1; private static void feedCow(int year,int age){ year++; age++; if(year<=30){ if... 阅读全文

posted @ 2009-10-30 13:45 泡泡饭 阅读(347) 评论(0) 推荐(0) 编辑