0804 递归

 public int ganyang(int i)
        {
            int sum=0;
              if(i==7)
              {
                  return 2;
              }
                 sum = (ganyang(i+1) + 1) * 2;
                 return sum;
        }

 


        public int chitao(int i)
        {
            int sum = 0;
            if (i == 9)
            {
                return 3;
            }
            sum = (ganyang(i + 1) + 1) *(4/3);
            return sum;
        }                                                                                                                                                                                             
                 
                                                      


        static void Main(string[] args)
        {
            //Program aa = new Program();
            //int sum = aa.ganyang(0);
            //Console.WriteLine("最初赶了{0}只羊.",sum);
            //Console.ReadLine();

            Program aa = new Program();
            int sum = aa.chitao(0);
            Console.WriteLine("最初摘了{0}个桃." , sum);
            Console.ReadLine();

posted @ 2016-08-08 16:09  王站住  阅读(66)  评论(0编辑  收藏  举报