zoukankan      html  css  js  c++  java
  • C#语言 语句

    //有一组函数:
    //y=x(x<1)
    //y=2x-1(1<=x<10)
    //y=3x-11(x>=10)
    //括号内是x的满足条件
    //实现功能,随意输出x
    /*Console.Write("请输入一个整数:");
    int x = int.Parse(Console.ReadLine());
    int y;
    if (x < 1)
    {
    y=x;
    Console.Write("y=x"+x);
    }
    if (1 <= x && x<10)
    {
    y=2*1-1;
    Console.Write("y=2*x-1" + y);
    }
    if (x >= 10)
    {
    y = 3 * x - 11;
    Console.Write("y=3*x-11"+y);
    }
    Console.ReadLine();*/

    if和else的嵌套


    //相亲过程:你有房子吗?你有钱吗?你有能力吗?
    //《结婚吧》《先买房子再结婚》《先赚钱再买房子再结婚》
    //什么都没有《那拜拜~》

    /*string a;
    Console.WriteLine("你有房子吗?");
    a = Console.ReadLine();
    if (a == "有")
    {
    Console.Write("结婚吧!");
    }
    else if (a == "没有")
    {
    Console.WriteLine("你有钱吗?");
    a = Console.ReadLine();
    if (a == "有")
    {
    Console.Write("先买房子再结婚吧!");
    }

    if (a == "没有")
    {
    Console.WriteLine("你有能力吗?");
    a = Console.ReadLine();
    if (a == "有")
    {
    Console.Write("那先赚钱买房子再结婚吧!");
    }
    if (a == "没有")
    {
    Console.WriteLine("滚犊子!");
    a = Console.ReadLine();
    }
    else
    {
    Console.Write("您输入有误");
    }
    }
    else
    {
    Console.Write("您输入有误");
    }
    }
    else
    {
    Console.Write("您输入有误");
    }
    Console.ReadLine();*/

    条件表达式:

    Console.Write("请输入一个整数:");
    int a = int.Parse(Console.ReadLine());
    Console.Write("请输入一个不同整数:");
    int b = int.Parse(Console.ReadLine());
    Console.Write("请输入一个不同整数:");
    int c = int.Parse(Console.ReadLine());
    //找出最小值赋值给min
    int min = (a < b && a < c) ? a : b;
    min = (b < a && b < c) ? b : min;
    min = (c < a && c < b) ? c : min;
    //找出最大值赋值给max
    int max = (a > b && a > c) ? a : b;
    max = (a > b && a > c) ? b : max;
    max = (c > a && c > b) ? c : max;
    //找出未赋值的值赋值给mid
    int mid = (min == a && max == c) ? b : a;
    mid = (min == a && max == b) ? c : mid;
    mid = (min == b && max == c) ? a : mid;

    Console.WriteLine(min+""+mid+""+max);
    Console.ReadLine();

  • 相关阅读:
    window.open
    GetPostBackClientHyperlink
    引发和使用事件
    浅谈宝宝的教育及培养
    C#关键字之:base、this
    Ioc
    自定义input[type="radio"]的样式
    选择_冒泡_直接插入排序.md
    Tkinter.md
    从零开始学wordpress 之一
  • 原文地址:https://www.cnblogs.com/a849788087/p/4923770.html
Copyright © 2011-2022 走看看