zoukankan      html  css  js  c++  java
  • 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();

  • 相关阅读:
    第一章 Java Collections Framework总览
    MySQL常用sql语句
    static关键字
    Mysql常用索引及优化
    JDK安装及环境变量配置
    破解IntelliJ IDEA 2017
    Spring自我总结
    Java中根据字节截取字符串
    外键的主要作用:保持数据的一致性、完整性
    使用SSI框架写的简单Demo(查询模块)
  • 原文地址:https://www.cnblogs.com/a12110303043/p/5749748.html
Copyright © 2011-2022 走看看