zoukankan      html  css  js  c++  java
  • 刚学了函数,关于有无参数和返回值的四种情况的查找数字的代码

    static void Main(string[] args)
    {
    ////无参无反
    //cz();

    ////无参有返
    //bool bbb = chaz();
    //if (bbb == true)
    //{
    // Console.WriteLine("找到啦");
    //}
    //else
    //{
    // Console.WriteLine("没找到");
    //}


    ////有参无返
    //Console.WriteLine("请输入一个数");
    //int d = Convert.ToInt32(Console.ReadLine());
    //chazhao(d);


    ////有参有返
    //Console.WriteLine("请输入一个数");
    //int d = Convert.ToInt32(Console.ReadLine());
    //bool b = chazhaoaaa(d);
    //if (b == true)
    //{
    // Console.WriteLine("找到啦");
    //}
    //else
    //{
    // Console.WriteLine("没找到");
    //}

    }
    //有参有返
    static bool chazhaoaaa(int d)
    {

    int[] a = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    bool b = false;
    for (int i = 0; i < a.Length; i++)
    {
    if (a[i] == d)
    {
    b = true;
    break;
    }


    }
    return b;

    }

    //有参无返
    static void chazhao(int d)
    {

    int[] a = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    bool b = false;
    for (int i = 0; i < a.Length; i++)
    {
    if (a[i] == d)
    {
    b = true;
    break;
    }


    }
    if (b == true)
    {
    Console.WriteLine("找到啦");
    }
    else
    {
    Console.WriteLine("没找到");
    }

    }


    //查找 无参有返
    static bool chaz()
    {
    bool b = false;
    Console.WriteLine("请输入一个数");
    int d = Convert.ToInt32(Console.ReadLine());
    int[] a = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };

    for (int i = 0; i < a.Length; i++)
    {
    if (a[i] == d)
    {
    b = true;
    break;
    }


    }

    return b;
    }


    //查找 无参无反
    static void cz()
    {
    Console.WriteLine("请输入一个数");
    int d=Convert.ToInt32(Console.ReadLine());
    int[] a = new int[10] { 1,2,3,4,5,6,7,8,9,0};
    bool b=false;
    for (int i = 0; i < a.Length; i++)
    {
    if (a[i]==d)
    {
    b = true;
    break;
    }


    }
    if (b == true)
    {
    Console.WriteLine("找到啦");
    }
    else
    {
    Console.WriteLine("没找到");
    }

  • 相关阅读:
    linux hosts文件详+mac主机名被莫名其妙修改
    WPF整理--动态绑定到Logical Resource
    WPF整理-使用逻辑资源
    WPF整理-自定义一个扩展标记(custom markup extension)
    WPF整理-XAML访问静态属性
    WPF整理-为控件添加自定义附加属性
    WPF整理-为User Control添加依赖属性
    使用MS Test进行单元测试
    WPF整理-XAML构建后台类对象
    毕业那点事儿--回顾在大学这7年
  • 原文地址:https://www.cnblogs.com/zzc134680/p/5429980.html
Copyright © 2011-2022 走看看