第十次学习

85 阅读1分钟

using System;

namespace ConsoleApp1 { internal class Program {

    public static bool Test1(out int num1, out string str1)
    {
        num1 = 12;
        str1 = "张三";
        return true;
    }

    public static bool Test2(ref int num2, ref string str2)
    {
        num2 = 12;
        str2 = "张三";
        return true;
    }

    public static bool login(String username, String password, out String loginMessage)
    {


        bool flag = true;
        if (username.Equals("zs"))
        {
            if (password.Equals("123456"))
            {
                loginMessage = "登录成功";
            }
            else
            {
                loginMessage = "密码错误";
                flag = false;
            }
        }
        else
        {
            loginMessage = "用户名错误";
            flag = false;
        }

        return flag;
    }

    public static int febo(int n)
    {
        if (n <= 2)
        {
            return 1;
        }

        return febo(n - 1) + febo(n - 2);
    }

    public static int mutiply(int n)
    {


        return mutiply(n) + n * n;
    }

    public static int peach(int day)
    {

        if (day == 10)
        {
            return 1;
        }
        return (peach(day + 1) + 1) * 2;
    }

    public static int upstairs(int n)
    {
        if (n == 1)
        {
            return 1;
        }
        if (n == 2)
        {
            return 2;
        }

        return upstairs(n - 1) + upstairs(n - 2);
    }

    public static void movieDesk(int n, String start, String middle, String end)
    {
        if (n == 1)
        {
            Console.WriteLine("从{0}移动到{1}", start, end);
            return;
        }
        movieDesk(n - 1, start, end, middle);


        movieDesk(1, start, middle, end);

        movieDesk(n - 1, middle, start, end);


    }
    public static void Main(string[] args)
    {
        /*
        int num1;
        int num2= 1;
        String str1;
        String str2=" "; //ref必须先初始化,out可不用
        Test1(out num1,out str1);
        Test2(ref num2, ref str2);

        Console.WriteLine("{0} {1}",num1,str1);
        Console.WriteLine("{0} {1}", num2, str2);
        */

        /*
        String loginMessage;
        String username = Console.ReadLine();
        String password = Console.ReadLine();

        login(username,password,out loginMessage);
        Console.WriteLine(loginMessage);

        */

        /*
        int n = Convert.ToInt32(Console.ReadLine());
        for(int i = 0;i<=n;i++){
             febo(i);
        }


        */
        /*
        int count = 0;
        for(int i = 1; ; i++)
        {
            if(mutiply(i) >= 2000)
            {
                count = i;
                break;
            }
        }
        Console.WriteLine(count-1);
        */
        /*
        for(int i = 1; i <= 10; i++)
        {
            Console.WriteLine(peach(i));
        }
        */
        /*
        int n = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine(  upstairs(n));
        */

        movieDesk(3, "a", "b", "c");
    }
}

}