您的位置:新葡亰496net > 奥门新萄京娱乐场 > 新葡亰496net:递归解法

新葡亰496net:递归解法

发布时间:2019-07-27 06:12编辑:奥门新萄京娱乐场浏览(97)

    掌故难点:有一对兔子,从降生后第五个月起种种月都生一对兔子,小兔子长到第七个月后每一种月又生一对兔子,借使兔子都不死,问每一种月的兔子总量为多少?

    一、概念

    C# 函数,

    函数:能够独立实现某项功用的模块。

    函数四要素:输入、输出、函数体、函数名

    函数定义:
    (static/public) 重回类型 函数名(参数类型 参数名,参数类型 参数名)
    {
    函数体
    }

    函数的调用:
    回去变量类型 变量名 = 函数(实参值)

    案例:输入七个数求阶乘(写成函数调用)
    /// <summary>
    /// 求阶乘
    /// </summary>
    public void Jie()
    {
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    Console.Write("阶乘结果是:" jie);
    Console.ReadLine();
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先须求将这么些类初始化一下
    hanshu.Jie();

    可写成:带传值的
    /// <summary>
    /// 求阶乘
    /// </summary>
    public void Jie(int a)
    {
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    Console.Write("阶乘结果是:" jie);
    Console.ReadLine();
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先必要将以此类开首化一下
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    hanshu.Jie(a);

    能够写成传值加重回值的:
    /// <summary>
    /// 求阶乘
    /// </summary>
    public int Jie(int a)
    {
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    return jie;
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先须求将这些类初阶化一下
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());

    Console.Write("阶乘结果是:" hanshu.Jie(a));
    Console.ReadLine();

    能够写成不传值可是带重回值的:
    /// <summary>
    /// 求阶乘
    /// </summary>
    public int Jie()
    {
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    return jie;
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先需求将这几个类先导化一下
    Console.Write("阶乘结果是:" hanshu.Jie());
    Console.ReadLine();

    例:写三个回去最大值的函数。调用。
    /// <summary>
    /// 八个数非常的大小重临大的
    /// </summary>
    /// <param name="a"></param>
    /// <param name="b"></param>
    /// <returns></returns>
    public int Max(int a, int b)
    {
    if (a > b)
    {
    return a;
    }
    else
    {
    return b;
    }
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先须要将以此类早先化一下
    Console.WriteLine(hanshu.Max(hanshu.Max(a, b), c));
    //函数不仅能够一再运用,仍可以够嵌套使用

    细化

    namespace 函数
    {
    class Program
    {
    格式1:无参无返
    <summary>
    累加求和,无需参数,未有再次来到值
    </summary>
    public void LeiJia()
    {
    累加求和
    Console.Write("请输入三个正整数:");
    int a = int.Parse(Console.ReadLine());
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    Console.WriteLine(sum);
    Console.ReadLine();
    }

     

    格式2:无参有返
    public int LeiJia1()
    {
    累加求和
    Console.Write("请输入贰个正整数:");
    int a = int.Parse(Console.ReadLine());
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }

    return sum;
    }

     

    格式3:有参有返
    public int LeiJia2(int a)
    {
    累加求和
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    return sum;
    }

    格式4:有参无返
    public void LeiJia3(int a)
    {
    累加求和
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    Console.WriteLine(sum);
    Console.ReadLine();
    }

    有参数表示在函数体中没有须求再去接受
    有重回值表示,笔者在下文中还亟需选择那一个结果
    在调用函数的时候必要定义三个均等数据类型的变量接收

    函数,极大小重返大的
    public double Max(double a, double b)
    {
    if (a > b)
    {
    return a;
    }
    else//a<=b
    {
    return b;
    }
    }
    函数可以嵌套使用,不过函数不能嵌套写

     

    public void you()//邮箱,无参无返
    {
    Console.Write("请输入邮箱:");
    string yx = Console.ReadLine();
    if(yx.Contains ("@"))
    {
    int a=yx.IndexOf ("@");
    int b=yx.LastIndexOf ("@");
    if (a == b)
    {
    if(!yx.StartsWith ("@"))
    {
    string c = yx.Substring(a);
    if(c.Contains ("."))
    {
    string d=yx.Substring (a-1,1);
    string e = yx.Substring(a, 1);
    if(d!="."&&e!=".")
    {
    if(!yx.EndsWith ("."))
    {
    Console.WriteLine("您输入的信箱格式准确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    新葡亰496net:递归解法。}
    }
    else
    {
    Console .WriteLine ("邮箱输入错误");
    }
    Console.ReadLine();
    }

     

     

    public string you2() //无参有返
    {
    Console.Write("请输入邮箱:");
    string yx = Console.ReadLine();
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的信箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    return yx;
    }

    有参有返
    public string you3(string yx)
    {
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    新葡亰496net:递归解法。{
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的邮箱格式精确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    return yx;
    }

    有参无返

    public void you4(string yx)
    {
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的信箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    Console.ReadLine();
    }

    加10分,给数组中的
    public double[] JiaFen(double[] score)
    {
    for (int i = 0; i < score.Length; i )
    {
    score[i] = 10;
    }
    return score;
    }

    public int renzong = 0;
    public int dianzong = 0;

    public string Cai()
    {
    Console.Write("请输入您出哪些拳(剪刀、石头、布):");
    string shu = Console.ReadLine();

    if (shu == "剪刀" || shu == "石头" || shu == "布")
    {
    int ren = 0;
    switch (shu)
    {
    case "剪刀":
    ren = 1;
    break;
    case "石头":
    ren = 2;
    break;
    case "布":
    ren = 3;
    break;
    }
    Random ran = new Random();
    int dian = ran.Next(1, 4);
    switch (dian)
    {
    case 1:
    Console.WriteLine("Computer出剪刀");
    break;
    case 2:
    Console.WriteLine("计算机出石头");
    break;
    case 3:
    Console.WriteLine("Computer出布");
    break;
    }
    int jie = ren - dian;
    if (jie == 0)
    {
    return "本轮平局!";
    }
    else if (jie == 1 || jie == -2)
    {
    return "本轮胜出!";
    }
    else
    {
    return "本轮战败!";
    }
    }
    else
    {
    return "输入有误!";
    }
    }
    public void tizhong()
    {
    Console.Write("请输入性别");
    string s = Console.ReadLine();
    Console.Write("请输入体重");
    double t = double.Parse(Console.ReadLine());
    Console.Write("请输入身体高度");
    double g = double.Parse(Console.ReadLine());
    if (s == "男")
    {
    double n = t - g 100;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是正规体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else if (s == "女")
    {
    double n = t - g 110;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是业内身体重量");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else
    {
    Console.WriteLine("您的输入有误");
    }
    Console.ReadLine();
    }

     

    static void Main(string[] args)
    {
    务求:写贰个函数,总计体重是或不是正规
    函数供给五个输入值,分别为性别、身体重量kg、身体高度cm
    男:身高-100=体重±3kg
    女:身高-110=体重±3kg
    Console.Write("请输入性别");
    string s = Console.ReadLine();
    Console.Write("请输入体重");
    double t = double.Parse(Console.ReadLine());
    Console.Write("请输入身体高度");
    double g = double.Parse(Console.ReadLine());
    if (s == "男")
    {
    double n = t - g 100;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是标准身体重量");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的身体重量偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else if (s == "女")
    {
    double n = t - g 110;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是正经体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else
    {
    Console.WriteLine("您的输入有误");
    }
    Console.ReadLine();
    Program hanshu = new Program();
    hanshu.tizhong();

     

    第一对于外市的类举办开头化
    Program hanshu = new Program();
    hanshu.LeiJia();
    int sum = hanshu.LeiJia1();
    在那么些数值上再加10分
    sum = 10;

    int sum= hanshu.LeiJia2(5);

    Console.WriteLine(sum);
    Console.ReadLine();

    hanshu.LeiJia3(5);

    Console.Write("请输入a=");
    double a = double.Parse(Console.ReadLine());
    Console.Write("请输入b=");
    double b = double.Parse(Console.ReadLine());
    Console.Write("请输入c=");
    double c = double.Parse(Console.ReadLine());
    double max = hanshu.Max( hanshu.Max(a,b),c);

    Console.WriteLine(max);
    Console.ReadLine();

    输入邮箱账号,决断是或不是格式正确
    Program han = new Program();
    han.you();

    string yx = han.you2( );
    Console.WriteLine(yx);
    Console.ReadLine();

     

    Console.WriteLine("请输入邮箱地址");
    string yx = han.you3(Console .ReadLine ());
    Console.WriteLine(yx);
    Console.ReadLine();

    Console.WriteLine("请输入邮箱地址");
    han.you4(Console .ReadLine ());

     

    需要输入班级人数,依据人口输入各样人的分数
    鉴于那个班都以少数民族,所以都急需加10分
    加10分的进度须要用到函数
    Console.Write("请输入班级人数:");
    int a = int.Parse(Console.ReadLine());
    double [] score =new double [a];
    for (int i = 0; i < a; i )
    {
    Console.Write("请输入第{0}个人的分数:",i 1);
    score[i] = double.Parse(Console.ReadLine());
    }
    Console.WriteLine("全体学员分数输入完结,请按回车键继续!");
    Console.ReadLine();
    初始化
    Program hanshu = new Program();
    score = hanshu.JiaFen(score);

    foreach (double aa in score)
    {
    Console.WriteLine(aa);
    }
    Console.ReadLine();

     

    猜拳:
    人机对战
    剪刀 1
    石头 2
    包袱 3
    人输入:(剪刀、石头、布)
    0 平局
    1 赢了
    -1 输了
    -2 赢了
    2 输了
    Console.Write("请输入您出什么样拳(剪刀、石头、布):");
    string shu = Console.ReadLine();

    if (shu == "剪刀" || shu == "石头" || shu == "布")
    {
    int ren = 0;
    switch (shu)
    {
    case "剪刀":
    ren = 1;
    break;
    case "石头":
    ren = 2;
    break;
    case "布":
    ren = 3;
    break;
    }
    Random ran = new Random();
    int dian = ran.Next(1, 4);
    switch (dian)
    {
    case 1:
    Console.WriteLine("Computer出剪刀");
    break;
    case 2:
    Console.WriteLine("Computer出石头");
    break;
    case 3:
    Console.WriteLine("Computer出布");
    break;
    }
    int jie = ren - dian;
    if (jie == 0)
    {
    Console.WriteLine("本轮平局!");
    }
    else if (jie == 1 || jie == -2)
    {
    Console.WriteLine("本轮胜出!");
    }
    else
    {
    Console.WriteLine("本轮败北!");
    }
    }
    else
    {
    Console.WriteLine("输入有误!");
    }

    Console.ReadLine();

     

    输入进度中若出错
    for (int i = 1; i > 0; i )
    {
    Console.Write("请输入是否!");
    string ss = Console.ReadLine();
    if (ss == "是" || ss == "不是")
    {
    break;
    }
    else
    {
    Console.WriteLine("输入有误!请重新输入!");
    }
    }
    输入年月日,查看时间日期格式是不是精确

    for (int i = 1; i > 0; i )
    {
    Console.Write("请输入年份:");
    int year = int.Parse(Console.ReadLine());
    if (year >= 0 && year <= 9999)
    {
    for (int a = 1; a > 0; a )
    {
    Console.Write("请输入月份:");
    int month = int.Parse(Console.ReadLine());
    if (month >= 1 && month <= 12)
    {
    for (int b = 1; b > 0; b )
    {
    Console.Write("请输入日期:");
    int day = int.Parse(Console.ReadLine());
    if (day >= 1 && day <= 31)
    {
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    {
    Console.WriteLine("您输入的日子格式准确,您输入的日期是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    if (month == 4 || month == 6 || month == 9 || month == 11)
    {
    if (day == 31)
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    else
    {
    Console.WriteLine("您输入的日期格式精确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    }
    else
    {
    if (day <= 28)
    {
    Console.WriteLine("您输入的日期格式精确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
    {
    if (day == 29)
    {
    Console.WriteLine("您输入的日期格式准确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    Console.WriteLine("您输入的日子错误,请重新输入!");
    continue;
    }
    }
    else
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    }
    }
    }
    }
    else
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    }
    a = -10;
    }
    else
    {
    Console.WriteLine("您输入的月度错误,请重新输入!");
    continue;
    }
    }
    }
    else
    {
    Console.WriteLine("您输入的年度错误,请重新输入!");
    continue;
    }
    i = -10;
    }Console.ReadLine();

     

    for (int i = 0; i < 5; i )
    {
    for (int j = 0; j < 5; j )
    {
    if (j == 3)
    {
    break;//break跳出近些日子的巡回
    }
    Console.Write("■");

    }
    Console.WriteLine();
    }

    Console.ReadLine();

    }
    }
    }

    函数, 函数:能够独立落成某项成效的模块。 函数四要素:输入、输出、函数体、函数名 函数定义: (static/public) 重回类型 函数名(...

    函数:能够单独实现某项功用的模块。

    函数:能够独立完结某项作用的模块。

    思路:先求出每一个月猛增的兔子,再用循环求和就能够算出下月总的兔子数。

    函数体内吊用本函数自个儿,直到适合某一尺码不在继续调用。

    函数四要素:输入、输出、函数体、函数名

    函数四要素:输入、输出、函数体、函数名

    月份  新扩展兔子

     

    函数定义:
    (static/public) 重临类型 函数名(参数类型 参数名,参数类型 参数名)
    {
    函数体
    }

    函数定义:
    (static/public) 再次来到类型 函数名(参数类型 参数名,参数类型 参数名)
    {
    函数体
    }

    1    1

    二、应满意自家条件

    函数的调用:
    重临变量类型 变量名 = 函数(实参值)

    函数的调用:
    回到变量类型 变量名 = 函数(实参值)

    2    0

    (1)有频仍施行的经过(调用本身);

    案例:输入一个数求阶乘(写成函数调用)
    /// <summary>
    /// 求阶乘
    /// </summary>
    public void Jie()
    {
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    Console.Write("阶乘结果是:" jie);
    Console.ReadLine();
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先要求将这一个类开端化一下
    hanshu.Jie();

    案例:输入二个数求阶乘(写成函数调用)
    /// <summary>
    /// 求阶乘
    /// </summary>
    public void Jie()
    {
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    Console.Write("阶乘结果是:" jie);
    Console.ReadLine();
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先需求将这么些类早先化一下
    hanshu.Jie();

    3    1

    (2)有跳出再三实践进度的口径(函数出口)

    可写成:带传值的
    /// <summary>
    /// 求阶乘
    /// </summary>
    public void Jie(int a)
    {
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    Console.Write("阶乘结果是:" jie);
    Console.ReadLine();
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先需求将这些类初叶化一下
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    hanshu.Jie(a);

    可写成:带传值的
    /// <summary>
    /// 求阶乘
    /// </summary>
    public void Jie(int a)
    {
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    Console.Write("阶乘结果是:" jie);
    Console.ReadLine();
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先供给将以此类开端化一下
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    hanshu.Jie(a);

    4    1

    三、例子

    能够写成传值加重回值的:
    /// <summary>
    /// 求阶乘
    /// </summary>
    public int Jie(int a)
    {
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    return jie;
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先供给将那几个类初叶化一下
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());

    能够写成传值加再次回到值的:
    /// <summary>
    /// 求阶乘
    /// </summary>
    public int Jie(int a)
    {
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    return jie;
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先要求将以此类起头化一下
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());

    5    1 1

    新葡亰496net 1

    Console.Write("阶乘结果是:" hanshu.Jie(a));
    Console.ReadLine();

    Console.Write("阶乘结果是:" hanshu.Jie(a));
    Console.ReadLine();

    6    1 1 1

    四、注意事项

    能够写成不传值可是带重回值的:
    /// <summary>
    /// 求阶乘
    /// </summary>
    public int Jie()
    {
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    return jie;
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先需求将以此类开始化一下
    Console.Write("阶乘结果是:" hanshu.Jie());
    Console.ReadLine();

    能够写成不传值可是带再次来到值的:
    /// <summary>
    /// 求阶乘
    /// </summary>
    public int Jie()
    {
    Console.Write("请输入a=");
    int a = int.Parse(Console.ReadLine());
    int jie = 1;
    for (int i = 1; i <= a; i )
    {
    jie *= i;
    }
    return jie;
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先须求将以此类起初化一下
    Console.Write("阶乘结果是:" hanshu.Jie());
    Console.ReadLine();

    7    (1 1 1)12月份激增的兔子 (1 1)一月份猛增的兔子

    1.递归中必必要留存二个周而复始停止的标准。

    例:写贰个回去最大值的函数。调用。
    /// <summary>
    /// 多少个数一点都不小小重临大的
    /// </summary>
    /// <param name="a"></param>
    /// <param name="b"></param>
    /// <returns></returns>
    public int Max(int a, int b)
    {
    if (a > b)
    {
    return a;
    }
    else
    {
    return b;
    }
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先要求将以此类开端化一下
    Console.WriteLine(hanshu.Max(hanshu.Max(a, b), c));
    //函数不仅可以够频仍应用,还能嵌套使用

    例:写贰个赶回最大值的函数。调用。
    /// <summary>
    /// 八个数一点都相当大小重返大的
    /// </summary>
    /// <param name="a"></param>
    /// <param name="b"></param>
    /// <returns></returns>
    public int Max(int a, int b)
    {
    if (a > b)
    {
    return a;
    }
    else
    {
    return b;
    }
    }
    static void Main(string[] args)
    {
    Program hanshu = new Program();
    //首先须求将那些类初叶化一下
    Console.WriteLine(hanshu.Max(hanshu.Max(a, b), c));
    //函数不仅可以够频仍接纳,还足以嵌套使用

    ...    ...

    2.递归函数的每趟调用都急需栈来积存,假若次数太多的话轻松形成栈溢出。

    细化

    细化

    n    n - 3月份新扩张的兔子 n - 一月份增加产量的兔子

    新葡亰496net 2

    namespace 函数
    {
    class Program
    {
    格式1:无参无返
    <summary>
    累加求和,不要求参数,未有重临值
    </summary>
    public void LeiJia()
    {
    累加求和
    Console.Write("请输入三个正整数:");
    int a = int.Parse(Console.ReadLine());
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    Console.WriteLine(sum);
    Console.ReadLine();
    }

    namespace 函数
    {
    class Program
    {
    格式1:无参无返
    <summary>
    累加求和,无需参数,没有重回值
    </summary>
    public void LeiJia()
    {
    累加求和
    Console.Write("请输入八个正整数:");
    int a = int.Parse(Console.ReadLine());
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    Console.WriteLine(sum);
    Console.ReadLine();
    }

    解法大旨:每种月的新添的兔子都在下当月以及今后的每一种月生下一对新兔子,这对新兔子在下前段时期以及随后的各种月都会生下一对新兔子,以此原理循环。

    例题:

     

     

        由此,只要前贰个月有新扩大的兔子后,上一个月都会陡增和上月新兔子数量同样的兔子,同一时间还可能会新扩张上前些时间兔子数量的新兔子。那七个数据相加就获得上个月一共新增的兔子。

    一堆羊赶到个村庄去卖,每过七个村遗失从前线总指挥部数的三分之二零一只,过了7个村落之后还剩五只,问最初赶出某些只羊

    格式2:无参有返
    public int LeiJia1()
    {
    累加求和
    Console.Write("请输入三个正整数:");
    int a = int.Parse(Console.ReadLine());
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }

    格式2:无参有返
    public int LeiJia1()
    {
    累加求和
    Console.Write("请输入贰个正整数:");
    int a = int.Parse(Console.ReadLine());
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }

    用递归的点子求出每种月猛增的兔子(自定义函数):

     class Program

    return sum;
    }

    return sum;
    }

            static int NewRabbitOfMonth(int n)
            {
                if(n == 1)
                {
                    return 1;
                }
                else if(n == 2)
                {
                    return 0;
                }
                else
                {
                    return NewRabbitOfMonth(n - 1) NewRabbitOfMonth(n - 2);
                }
            }

    {
    public int dgqiuyang(int cun)
    {
    int sum = 0;
    if (cun == 7)
    {
    return 2;
    }
    sum = 2*(dgqiuyang(cun 1) 1);
    return sum;
    }

     

     

    用循环求和的措施求出各种月的兔子总的数量(主函数):

    static void Main(string[] args)
    {

    格式3:有参有返
    public int LeiJia2(int a)
    {
    累加求和
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    return sum;
    }

    格式3:有参有返
    public int LeiJia2(int a)
    {
    累加求和
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    return sum;
    }

            static void Main(string[] args)
            {
                Console.Write("请输入第多少个月:");
                int n = int.Parse(Console.ReadLine());
                int sumRabbitOfMonth = 0;
                for(int i =1; i <= n; i )
                {
                    sumRabbitOfMonth = NewRabbitOfMonth(i);
                }
                Console.Write("第" n "个月共有" sumRabbitOfMonth "对兔子");
                Console.ReadLine();
            }

    Program hb = new Program();
    double x = hb.dgqiuyang(1);

    格式4:有参无返
    public void LeiJia3(int a)
    {
    累加求和
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    Console.WriteLine(sum);
    Console.ReadLine();
    }

    格式4:有参无返
    public void LeiJia3(int a)
    {
    累加求和
    int sum = 0;
    for (int i = 1; i <= a; i )
    {
    sum = i;
    }
    Console.WriteLine(sum);
    Console.ReadLine();
    }

    思考:

    Console.Write("递归求羊" x);

    有参数表示在函数体中没有必要再去接受
    有再次回到值表示,小编在下文中还索要利用那些结果
    在调用函数的时候供给定义多少个平等数据类型的变量接收

    有参数表示在函数体中无需再去接受
    有重临值表示,小编在下文中还索要选拔这一个结果
    在调用函数的时候要求定义二个一致数据类型的变量接收

    种种月猛增的兔子数量实在是一个斐波拉契数列:
    1,0,1,1,2,3,5...

    Console.ReadLine();

    函数,十分的大小重回大的
    public double Max(double a, double b)
    {
    if (a > b)
    {
    return a;
    }
    else//a<=b
    {
    return b;
    }
    }
    函数能够嵌套使用,不过函数不得以嵌套写

    函数,一点都十分大小重临大的
    public double Max(double a, double b)
    {
    if (a > b)
    {
    return a;
    }
    else//a<=b
    {
    return b;
    }
    }
    函数能够嵌套使用,不过函数不可以嵌套写

    种种月总的兔子数量也是一个斐波拉契数列:

    }

     

     

    1,1,2,3,5,8,13...

    }
    }

    public void you()//邮箱,无参无返
    {
    Console.Write("请输入邮箱:");
    string yx = Console.ReadLine();
    if(yx.Contains ("@"))
    {
    int a=yx.IndexOf ("@");
    int b=yx.LastIndexOf ("@");
    if (a == b)
    {
    if(!yx.StartsWith ("@"))
    {
    string c = yx.Substring(a);
    if(c.Contains ("."))
    {
    string d=yx.Substring (a-1,1);
    string e = yx.Substring(a, 1);
    if(d!="."&&e!=".")
    {
    if(!yx.EndsWith ("."))
    {
    Console.WriteLine("您输入的信箱格式精确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    public void you()//邮箱,无参无返
    {
    Console.Write("请输入邮箱:");
    string yx = Console.ReadLine();
    if(yx.Contains ("@"))
    {
    int a=yx.IndexOf ("@");
    int b=yx.LastIndexOf ("@");
    if (a == b)
    {
    if(!yx.StartsWith ("@"))
    {
    string c = yx.Substring(a);
    if(c.Contains ("."))
    {
    string d=yx.Substring (a-1,1);
    string e = yx.Substring(a, 1);
    if(d!="."&&e!=".")
    {
    if(!yx.EndsWith ("."))
    {
    Console.WriteLine("您输入的邮箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    下边个数列各个减去地点个数据每一样得到的新数列也是斐波拉契数列:

    例题:

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console .WriteLine ("邮箱输入错误");
    }
    Console.ReadLine();
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console .WriteLine ("邮箱输入错误");
    }
    Console.ReadLine();
    }

    0,1,1,2,3,5,8...

     

     

     

    结论:

    //编写递归函数求 2*4*6*……*(2n) 的结果
    public int dgqiuyang(int cun)
    {
    int sum = 0;
    if (cun == 7)
    {
    return 2;
    }
    sum = 2 * (dgqiuyang(cun 1) 1);
    return sum;
    }

     

     

    多少个斐波拉契数量的每一种减去另三个斐波拉契数列的相应各种获得的新数列也是斐波拉契数列。(待验证)

    static void Main(string[] args)

    public string you2() //无参有返
    {
    Console.Write("请输入邮箱:");
    string yx = Console.ReadLine();
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的邮箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    public string you2() //无参有返
    {
    Console.Write("请输入邮箱:");
    string yx = Console.ReadLine();
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的信箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

     

    {
    //Program jie= new Program();

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    //Console.Write("请输入五个值:");
    //int n = int.Parse(Console.ReadLine());
    //int b = jie.jie(n);
    //Console.Write(b);
    //Console.ReadLine();

    return yx;
    }

    return yx;
    }

    //有雌雄一对兔子,每过3个月便可繁衍雌雄各一的一对小兔子。

    有参有返
    public string you3(string yx)
    {
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的信箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    有参有返
    public string you3(string yx)
    {
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的信箱格式准确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    //问过n个月后共有多少对兔子?

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    return yx;
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    return yx;
    }

    public int t(int z)
    {
    int sh = 0;
    if (z == 1)
    {
    return 2;
    }
    sh = 2 * t(z - 1);
    return sh;
    }

    有参无返

    有参无返

    static void Main(string[] args)

    public void you4(string yx)
    {
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的邮箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    public void you4(string yx)
    {
    if (yx.Contains("@"))
    {
    int a = yx.IndexOf("@");
    int b = yx.LastIndexOf("@");
    if (a == b)
    {
    if (!yx.StartsWith("@"))
    {
    string c = yx.Substring(a);
    if (c.Contains("."))
    {
    string d = yx.Substring(a - 1, 1);
    string e = yx.Substring(a, 1);
    if (d != "." && e != ".")
    {
    if (!yx.EndsWith("."))
    {
    Console.WriteLine("您输入的信箱格式正确");
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }

    {
    //Program tt = new Program();
    //Console.Write("请输入月数:");
    //int m = int.Parse(Console.ReadLine());
    //int y = tt.t(m);
    //Console.Write(y);
    //Console.ReadLine();

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    Console.ReadLine();
    }

    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    }
    else
    {
    Console.WriteLine("邮箱输入错误");
    }
    Console.ReadLine();
    }

     

    加10分,给数组中的
    public double[] JiaFen(double[] score)
    {
    for (int i = 0; i < score.Length; i )
    {
    score[i] = 10;
    }
    return score;
    }

    加10分,给数组中的
    public double[] JiaFen(double[] score)
    {
    for (int i = 0; i < score.Length; i )
    {
    score[i] = 10;
    }
    return score;
    }

    //5个候选人公投班长:张三,李四,王五,赵六,冯七
    //班级中国共产党有二十一位,20个人轮换投票
    //只要不是1~5之内的正是作废
    //最终要明了哪个人的票的数量最多,当选班长

    public int renzong = 0;
    public int dianzong = 0;

    public int renzong = 0;
    public int dianzong = 0;

     

    public string Cai()
    {
    Console.Write("请输入您出什么样拳(剪刀、石头、布):");
    string shu = Console.ReadLine();

    public string Cai()
    {
    Console.Write("请输入您出如何拳(剪刀、石头、布):");
    string shu = Console.ReadLine();

    enum Houxuanren : int
    {
    one = 1,
    two,
    three,
    four,
    five
    }

    if (shu == "剪刀" || shu == "石头" || shu == "布")
    {
    int ren = 0;
    switch (shu)
    {
    case "剪刀":
    ren = 1;
    break;
    case "石头":
    ren = 2;
    break;
    case "布":
    ren = 3;
    break;
    }
    Random ran = new Random();
    int dian = ran.Next(1, 4);
    switch (dian)
    {
    case 1:
    Console.WriteLine("计算机出剪刀");
    break;
    case 2:
    Console.WriteLine("Computer出石头");
    break;
    case 3:
    Console.WriteLine("Computer出布");
    break;
    }
    int jie = ren - dian;
    if (jie == 0)
    {
    return "本轮平局!";
    }
    else if (jie == 1 || jie == -2)
    {
    return "本轮胜出!";
    }
    else
    {
    return "本轮退步!";
    }
    }
    else
    {
    return "输入有误!";
    }
    }
    public void tizhong()
    {
    Console.Write("请输入性别");
    string s = Console.ReadLine();
    Console.Write("请输入体重");
    double t = double.Parse(Console.ReadLine());
    Console.Write("请输入身体高度");
    double g = double.Parse(Console.ReadLine());
    if (s == "男")
    {
    double n = t - g 100;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是正式体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else if (s == "女")
    {
    double n = t - g 110;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是正规体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else
    {
    Console.WriteLine("您的输入有误");
    }
    Console.ReadLine();
    }

    if (shu == "剪刀" || shu == "石头" || shu == "布")
    {
    int ren = 0;
    switch (shu)
    {
    case "剪刀":
    ren = 1;
    break;
    case "石头":
    ren = 2;
    break;
    case "布":
    ren = 3;
    break;
    }
    Random ran = new Random();
    int dian = ran.Next(1, 4);
    switch (dian)
    {
    case 1:
    Console.WriteLine("Computer出剪刀");
    break;
    case 2:
    Console.WriteLine("计算机出石头");
    break;
    case 3:
    Console.WriteLine("Computer出布");
    break;
    }
    int jie = ren - dian;
    if (jie == 0)
    {
    return "本轮平局!";
    }
    else if (jie == 1 || jie == -2)
    {
    return "本轮胜出!";
    }
    else
    {
    return "本轮败北!";
    }
    }
    else
    {
    return "输入有误!";
    }
    }
    public void tizhong()
    {
    Console.Write("请输入性别");
    string s = Console.ReadLine();
    Console.Write("请输入体重");
    double t = double.Parse(Console.ReadLine());
    Console.Write("请输入身体高度");
    double g = double.Parse(Console.ReadLine());
    if (s == "男")
    {
    double n = t - g 100;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是标准体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else if (s == "女")
    {
    double n = t - g 110;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是正经体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else
    {
    Console.WriteLine("您的输入有误");
    }
    Console.ReadLine();
    }

    Console.WriteLine("请输入选举班长的代码1、2、3、4、5来分别代表 张三, 李四, 王五, 赵六, 冯七");

     

     

     

    static void Main(string[] args)
    {
    供给:写二个函数,总结体重是或不是正规
    函数须要三个输入值,分别为性别、体重kg、身体高度cm
    男:身高-100=体重±3kg
    女:身高-110=体重±3kg
    Console.Write("请输入性别");
    string s = Console.ReadLine();
    Console.Write("请输入体重");
    double t = double.Parse(Console.ReadLine());
    Console.Write("请输入身高");
    double g = double.Parse(Console.ReadLine());
    if (s == "男")
    {
    double n = t - g 100;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是标准体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else if (s == "女")
    {
    double n = t - g 110;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是正经体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else
    {
    Console.WriteLine("您的输入有误");
    }
    Console.ReadLine();
    Program hanshu = new Program();
    hanshu.tizhong();

    static void Main(string[] args)
    {
    务求:写一个函数,总计体重是不是正规
    函数供给八个输入值,分别为性别、身体重量kg、身体高度cm
    男:身高-100=体重±3kg
    女:身高-110=体重±3kg
    Console.Write("请输入性别");
    string s = Console.ReadLine();
    Console.Write("请输入体重");
    double t = double.Parse(Console.ReadLine());
    Console.Write("请输入身体高度");
    double g = double.Parse(Console.ReadLine());
    if (s == "男")
    {
    double n = t - g 100;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是明媒正娶体重");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的体重偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else if (s == "女")
    {
    double n = t - g 110;
    if (n > 3 && n <= -3)
    {
    Console.WriteLine("您是规范身体重量");
    }
    else if (n > 3)
    {
    Console.WriteLine("您的身体重量偏胖");
    }
    else
    {
    Console.WriteLine("您的体重偏瘦");
    }
    }
    else
    {
    Console.WriteLine("您的输入有误");
    }
    Console.ReadLine();
    Program hanshu = new Program();
    hanshu.tizhong();

    int[] shuzu = new int[20];
    for (int i = 1; i <= 20; i )
    {
    Console.Write("请第" i "位同学来拓展投票:");
    shuzu[i - 1] = int.Parse(Console.ReadLine());
    }
    Console.WriteLine("投票结束!按下回车开首总计票的数量!");
    Console.ReadLine();
    int zhangsan = 0, lisi = 0, wangwu = 0, zhaoliu = 0, fengqi = 0, zuofei = 0;
    for (int i = 0; i < 20; i )
    {
    switch (shuzu[i])
    {
    case (int)Houxuanren.one:
    zhangsan ;
    break;
    case (int)Houxuanren.two:
    lisi ;
    break;

     

     

     

    率先对另外地的类举办初叶化
    Program hanshu = new Program();
    hanshu.LeiJia();
    int sum = hanshu.LeiJia1();
    在那个数值上再加10分
    sum = 10;

    第一对于各市的类进行开头化
    Program hanshu = new Program();
    hanshu.LeiJia();
    int sum = hanshu.LeiJia1();
    在那个数值上再加10分
    sum = 10;

    case (int)Houxuanren.three:
    wangwu ;
    break;

    int sum= hanshu.LeiJia2(5);

    int sum= hanshu.LeiJia2(5);

     

    Console.WriteLine(sum);
    Console.ReadLine();

    Console.WriteLine(sum);
    Console.ReadLine();

    case (int)Houxuanren.four:
    zhaoliu ;
    break;

    hanshu.LeiJia3(5);

    hanshu.LeiJia3(5);

     

    Console.Write("请输入a=");
    double a = double.Parse(Console.ReadLine());
    Console.Write("请输入b=");
    double b = double.Parse(Console.ReadLine());
    Console.Write("请输入c=");
    double c = double.Parse(Console.ReadLine());
    double max = hanshu.Max( hanshu.Max(a,b),c);

    Console.Write("请输入a=");
    double a = double.Parse(Console.ReadLine());
    Console.Write("请输入b=");
    double b = double.Parse(Console.ReadLine());
    Console.Write("请输入c=");
    double c = double.Parse(Console.ReadLine());
    double max = hanshu.Max( hanshu.Max(a,b),c);

    case (int)Houxuanren.five:
    fengqi ;
    break;
    default:
    zuofei ;
    break;
    }

    Console.WriteLine(max);
    Console.ReadLine();

    Console.WriteLine(max);
    Console.ReadLine();

     

    输入邮箱账号,判定是或不是格式准确
    Program han = new Program();
    han.you();

    输入邮箱账号,判定是或不是格式正确
    Program han = new Program();
    han.you();

    }
    if (zhangsan > lisi && zhangsan > wangwu && zhangsan > zhaoliu && zhangsan > fengqi)
    {
    Console.WriteLine("张三胜出!票的数量为" zhangsan);
    }
    else if (lisi > zhangsan && lisi > wangwu && lisi > zhaoliu && lisi > fengqi)
    {
    Console.WriteLine("李四胜出!票的数量为" lisi);
    }
    else if (wangwu > lisi && wangwu > zhangsan && wangwu > zhaoliu && wangwu > fengqi)
    {
    Console.WriteLine("王五胜出!票的数量为" wangwu);
    }
    else if (zhaoliu > lisi && zhaoliu > wangwu && zhaoliu > zhangsan && zhaoliu > fengqi)
    {
    Console.WriteLine("赵六胜出!票的数量为" zhaoliu);
    }
    else if (fengqi > lisi && fengqi > wangwu && fengqi > zhaoliu && fengqi > zhangsan)
    {
    Console.WriteLine("冯七胜出!票的数量为" fengqi);
    }
    Console.WriteLine("作废的票的数量为:" zuofei);
    Console.ReadLine();

    string yx = han.you2( );
    Console.WriteLine(yx);
    Console.ReadLine();

    string yx = han.you2( );
    Console.WriteLine(yx);
    Console.ReadLine();

     

     

     

     

    Console.WriteLine("请输入邮箱地址");
    string yx = han.you3(Console .ReadLine ());
    Console.WriteLine(yx);
    Console.ReadLine();

    Console.WriteLine("请输入邮箱地址");
    string yx = han.you3(Console .ReadLine ());
    Console.WriteLine(yx);
    Console.ReadLine();

     

    Console.WriteLine("请输入邮箱地址");
    han.you4(Console .ReadLine ());

    Console.WriteLine("请输入邮箱地址");
    han.you4(Console .ReadLine ());

    }
    }
    }

     

     

     

    渴求输入班级人数,依据人数输入每一种人的分数
    由于这一个班都以少数民族,所以都亟需加10分
    加10分的进度供给用到函数
    Console.Write("请输入班级人数:");
    int a = int.Parse(Console.ReadLine());
    double [] score =new double [a];
    for (int i = 0; i < a; i )
    {
    Console.Write("请输入第{0}个人的分数:",i 1);
    score[i] = double.Parse(Console.ReadLine());
    }
    Console.WriteLine("全数学面生数输入完结,请按回车键继续!");
    Console.ReadLine();
    初始化
    Program hanshu = new Program();
    score = hanshu.JiaFen(score);

    渴求输入班级人数,依据人数输入各个人的分数
    出于那个班都是少数民族,所以都亟待加10分
    加10分的长河须求用到函数
    Console.Write("请输入班级人数:");
    int a = int.Parse(Console.ReadLine());
    double [] score =new double [a];
    for (int i = 0; i < a; i )
    {
    Console.Write("请输入第{0}个人的分数:",i 1);
    score[i] = double.Parse(Console.ReadLine());
    }
    Console.WriteLine("全部学不熟悉数输入实现,请按回车键继续!");
    Console.ReadLine();
    初始化
    Program hanshu = new Program();
    score = hanshu.JiaFen(score);

    foreach (double aa in score)
    {
    Console.WriteLine(aa);
    }
    Console.ReadLine();

    foreach (double aa in score)
    {
    Console.WriteLine(aa);
    }
    Console.ReadLine();

     

     

    猜拳:
    人机迎战
    剪刀 1
    石头 2
    包袱 3
    人输入:(剪刀、石头、布)
    0 平局
    1 赢了
    -1 输了
    -2 赢了
    2 输了
    Console.Write("请输入您出哪些拳(剪刀、石头、布):");
    string shu = Console.ReadLine();

    猜拳:
    人机对阵
    剪刀 1
    石头 2
    包袱 3
    人输入:(剪刀、石头、布)
    0 平局
    1 赢了
    -1 输了
    -2 赢了
    2 输了
    Console.Write("请输入您出哪些拳(剪刀、石头、布):");
    string shu = Console.ReadLine();

    if (shu == "剪刀" || shu == "石头" || shu == "布")
    {
    int ren = 0;
    switch (shu)
    {
    case "剪刀":
    ren = 1;
    break;
    case "石头":
    ren = 2;
    break;
    case "布":
    ren = 3;
    break;
    }
    Random ran = new Random();
    int dian = ran.Next(1, 4);
    switch (dian)
    {
    case 1:
    Console.WriteLine("计算机出剪刀");
    break;
    case 2:
    Console.WriteLine("Computer出石头");
    break;
    case 3:
    Console.WriteLine("计算机出布");
    break;
    }
    int jie = ren - dian;
    if (jie == 0)
    {
    Console.WriteLine("本轮平局!");
    }
    else if (jie == 1 || jie == -2)
    {
    Console.WriteLine("本轮胜出!");
    }
    else
    {
    Console.WriteLine("本轮失败!");
    }
    }
    else
    {
    Console.WriteLine("输入有误!");
    }

    if (shu == "剪刀" || shu == "石头" || shu == "布")
    {
    int ren = 0;
    switch (shu)
    {
    case "剪刀":
    ren = 1;
    break;
    case "石头":
    ren = 2;
    break;
    case "布":
    ren = 3;
    break;
    }
    Random ran = new Random();
    int dian = ran.Next(1, 4);
    switch (dian)
    {
    case 1:
    Console.WriteLine("计算机出剪刀");
    break;
    case 2:
    Console.WriteLine("计算机出石头");
    break;
    case 3:
    Console.WriteLine("计算机出布");
    break;
    }
    int jie = ren - dian;
    if (jie == 0)
    {
    Console.WriteLine("本轮平局!");
    }
    else if (jie == 1 || jie == -2)
    {
    Console.WriteLine("本轮胜出!");
    }
    else
    {
    Console.WriteLine("本轮失利!");
    }
    }
    else
    {
    Console.WriteLine("输入有误!");
    }

    Console.ReadLine();

    Console.ReadLine();

     

     

    输入进程中若出错
    for (int i = 1; i > 0; i )
    {
    Console.Write("请输入是要么不是!");
    string ss = Console.ReadLine();
    if (ss == "是" || ss == "不是")
    {
    break;
    }
    else
    {
    Console.WriteLine("输入有误!请重新输入!");
    }
    }
    输入年月日,查看时间日期格式是或不是科学

    输入进度中若出错
    for (int i = 1; i > 0; i )
    {
    Console.Write("请输入是要么不是!");
    string ss = Console.ReadLine();
    if (ss == "是" || ss == "不是")
    {
    break;
    }
    else
    {
    Console.WriteLine("输入有误!请重新输入!");
    }
    }
    输入年月日,查看时间日期格式是还是不是科学

    for (int i = 1; i > 0; i )
    {
    Console.Write("请输入年份:");
    int year = int.Parse(Console.ReadLine());
    if (year >= 0 && year <= 9999)
    {
    for (int a = 1; a > 0; a )
    {
    Console.Write("请输入月份:");
    int month = int.Parse(Console.ReadLine());
    if (month >= 1 && month <= 12)
    {
    for (int b = 1; b > 0; b )
    {
    Console.Write("请输入日期:");
    int day = int.Parse(Console.ReadLine());
    if (day >= 1 && day <= 31)
    {
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    新葡亰496net,{
    Console.WriteLine("您输入的日子格式正确,您输入的日期是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    if (month == 4 || month == 6 || month == 9 || month == 11)
    {
    if (day == 31)
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    else
    {
    Console.WriteLine("您输入的日期格式准确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    }
    else
    {
    if (day <= 28)
    {
    Console.WriteLine("您输入的日期格式准确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
    {
    if (day == 29)
    {
    Console.WriteLine("您输入的日期格式精确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    Console.WriteLine("您输入的日子错误,请重新输入!");
    continue;
    }
    }
    else
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    }
    }
    }
    }
    else
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    }
    a = -10;
    }
    else
    {
    Console.WriteLine("您输入的月度错误,请重新输入!");
    continue;
    }
    }
    }
    else
    {
    Console.WriteLine("您输入的年份错误,请重新输入!");
    continue;
    }
    i = -10;
    }Console.ReadLine();

    for (int i = 1; i > 0; i )
    {
    Console.Write("请输入年份:");
    int year = int.Parse(Console.ReadLine());
    if (year >= 0 && year <= 9999)
    {
    for (int a = 1; a > 0; a )
    {
    Console.Write("请输入月份:");
    int month = int.Parse(Console.ReadLine());
    if (month >= 1 && month <= 12)
    {
    for (int b = 1; b > 0; b )
    {
    Console.Write("请输入日期:");
    int day = int.Parse(Console.ReadLine());
    if (day >= 1 && day <= 31)
    {
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    {
    Console.WriteLine("您输入的日子格式精确,您输入的日期是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    if (month == 4 || month == 6 || month == 9 || month == 11)
    {
    if (day == 31)
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    else
    {
    Console.WriteLine("您输入的日期格式正确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    }
    else
    {
    if (day <= 28)
    {
    Console.WriteLine("您输入的日期格式精确,您输入的日子是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
    {
    if (day == 29)
    {
    Console.WriteLine("您输入的日期格式精确,您输入的日期是:{0}年{1}月{2}日", year, month, day);
    break;
    }
    else
    {
    Console.WriteLine("您输入的日子错误,请重新输入!");
    continue;
    }
    }
    else
    {
    Console.WriteLine("您输入的日期错误,请重新输入!");
    continue;
    }
    }
    }
    }
    }
    else
    {
    Console.WriteLine("您输入的日子错误,请重新输入!");
    continue;
    }
    }
    a = -10;
    }
    else
    {
    Console.WriteLine("您输入的月度错误,请重新输入!");
    continue;
    }
    }
    }
    else
    {
    Console.WriteLine("您输入的年份错误,请重新输入!");
    continue;
    }
    i = -10;
    }Console.ReadLine();

     

     

    for (int i = 0; i < 5; i )
    {
    for (int j = 0; j < 5; j )
    {
    if (j == 3)
    {
    break;//break跳出近年来的巡回
    }
    Console.Write("■");

    for (int i = 0; i < 5; i )
    {
    for (int j = 0; j < 5; j )
    {
    if (j == 3)
    {
    break;//break跳出前段时间的轮回
    }
    Console.Write("■");

    }
    Console.WriteLine();
    }

    }
    Console.WriteLine();
    }

    Console.ReadLine();

    Console.ReadLine();

    }
    }
    }

    }
    }
    }

    本文由新葡亰496net发布于奥门新萄京娱乐场,转载请注明出处:新葡亰496net:递归解法

    关键词: