zoukankan      html  css  js  c++  java
  • 分支语句--------典型案例

    今天略微整理了一下分支语句的几个典型案例,清晰、清晰、清晰。重要的事情说三遍!!

    //案例1  年龄段

    static void Main1(string[] args)
    {//年龄段
    Console.WriteLine("请输入你的年龄:");
    int nl = Convert.ToInt32(Console.ReadLine());
    if (nl >= 18 && nl < 30)
    {
    Console.WriteLine("青年");
    }
    else if (nl >= 30 && nl < 60)
    {
    Console.WriteLine("中年");
    }
    else if (nl >= 60 && nl < 135)
    {
    Console.WriteLine("老年");
    }
    else if (nl >= 0 && nl < 18)
    {
    Console.WriteLine("未成年");
    }
    else
    {
    Console.WriteLine("输入有误");
    }
    }

    //案例2 问候
    static void Main2(string[] args)
    {//问候
    Console.WriteLine("输入时间:");
    int h = Convert.ToInt32(Console.ReadLine());
    if (h >= 0 && h < 6)
    {
    Console.WriteLine("晚上没睡吗,别这样啊");
    }
    else if (h >= 6 && h < 11)
    {
    Console.WriteLine("早上好");
    }
    else if (h >= 11 && h < 18)
    {
    Console.WriteLine("下午好");
    }
    else if (h >= 18 && h < 22)
    {
    Console.WriteLine("晚上好");
    }
    else if (h >= 22 && h < 23)
    {
    Console.WriteLine("太晚了,注意休息");
    }
    else
    {
    Console.WriteLine("输入有误,时间不对啊");
    }

    }

    //案例3 输入月份显示多少天
    static void Main1212(string[] args)
    {//输入月份显示多少天
    //Console.WriteLine("请输入当前年份");
    //int year = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine("请输入当前月份:");
    int month = Convert.ToInt32(Console.ReadLine());

    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    {
    Console.WriteLine("本月有31天");
    }
    else if (month == 4 || month == 6 || month == 8 || month == 10)
    {
    Console.WriteLine("本月有30天");
    }
    else
    {
    Console.WriteLine("请输入年份:");
    int year = Convert.ToInt32(Console.ReadLine());
    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
    {
    Console.WriteLine("本月有29天");
    }
    else
    {
    Console.WriteLine("本月有28天");
    }
    }
    }

    //案例4 输入年、月、日,判断对不对
    static void Main(string[] args)
    {
    Console.WriteLine("请输入年份:");
    int year = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine("请输入月份:");
    int month = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine("请输入日期:");
    int day = Convert.ToInt32(Console.ReadLine());
    //判断
    #region
    if (year >= -9999 && year <= 9999)
    {
    Console.WriteLine("年份对");
    //Console.WriteLine("请输入月份:");
    //int month = Convert.ToInt32(Console.ReadLine());
    if (month >= 1 && month <= 12)
    {
    Console.WriteLine("月份对");
    //Console.WriteLine("请输入日期:");
    //int day = Convert.ToInt32(Console.ReadLine());
    if (day >= 1 && day <= 31)
    {
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    {
    Console.WriteLine("天对");
    }
    else if (month == 4 || month == 6 || month == 9 || month == 11)
    {
    if (day >= 1 && day <= 30)
    {
    Console.WriteLine("天对");
    }
    else
    {
    Console.WriteLine("天错");
    }
    }
    else
    {
    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
    {
    if (day >= 1 && day <= 29)
    {
    Console.WriteLine("天对");
    }
    else
    {
    Console.WriteLine("天错");
    }
    }
    else
    {
    if (day >= 1 && day <= 28)
    {
    Console.WriteLine("天对");
    }
    else
    {
    Console.WriteLine("天错");
    }
    }

    }
    }
    else
    {
    Console.WriteLine("天错");
    }
    }
    else
    {
    Console.WriteLine("月不对");
    }
    }
    else
    {
    Console.WriteLine("年份不对");

    }
    #endregion
    }

    //案例5 相亲问题
    static void Main555(string[] args)
    {
    string fangzi, qian, nengli;
    Console.WriteLine("姑娘:帅哥,有房子吗?");
    fangzi = Console.ReadLine();

    if (fangzi == "有")
    {
    Console.WriteLine("咱们结婚吧");
    }
    else
    {
    Console.WriteLine("姑娘:有钱吗?");
    qian = Console.ReadLine();
    if (qian == "有")
    {
    Console.WriteLine("先买房子,在结婚吧");
    }
    else
    {
    Console.WriteLine("姑娘:能力有吗?");
    nengli = Console.ReadLine();
    if (nengli == "有")
    {
    Console.WriteLine("努力赚钱结婚吧");
    }
    else
    {
    Console.WriteLine("拜拜啊");
    }
    }
    }
    }

    //案例6 猜数问题、中奖问题
    static void Main666(string[] args)
    {
    int a, b, c;
    int czgs = 0;
    Random rand = new Random();
    a = rand.Next(100);
    b = rand.Next(100);
    c = rand.Next(100);

    Console.WriteLine("请输入五个100以内的整数:");
    Console.Write("第一个:");
    int x1 = Convert.ToInt32(Console.ReadLine());
    Console.Write("第二个:");
    int x2 = Convert.ToInt32(Console.ReadLine());
    Console.Write("第三个:");
    int x3 = Convert.ToInt32(Console.ReadLine());
    Console.Write("第四个:");
    int x4 = Convert.ToInt32(Console.ReadLine());
    Console.Write("第五个:");
    int x5 = Convert.ToInt32(Console.ReadLine());

    Console.Clear();
    Console.ForegroundColor = ConsoleColor.Yellow;
    Console.BackgroundColor = ConsoleColor.Red;
    if (x1 == a || x1 == b || x1 == c)
    {
    czgs++;
    }
    if (x2 == a || x2 == b || x2 == b)
    {
    czgs++;
    }
    if (x3 == a || x3 == b || x3 == c)
    {
    czgs++;
    }
    if (x4 == a || x4 == b || x4 == c)
    {
    czgs++;
    }
    if (x5 == a || x5 == b || x5 == c)
    {
    ++czgs;
    }

    Console.WriteLine("本期的中奖号码是:{0} {1} {2}", a, b, c);
    if (czgs == 0)
    {
    Console.WriteLine("谢谢参与,下次努力哦");
    }
    else if (czgs == 1)
    {
    Console.WriteLine("恭喜你,中了10块钱");
    }
    else if (czgs == 2)
    {
    Console.WriteLine("恭喜你,中了100元");
    }
    else if (czgs == 3)
    {
    Console.WriteLine("恭喜你,中了1000元");
    }
    else
    {
    Console.WriteLine("恭喜你,中了1万元。");
    }
    }

     

    //案例9 个税

    static void Main99(string[] args)
    {//输入                                                                                                            
    double yx, ss = 0, a, gs = 0, sl = 0;
    Console.WriteLine("月薪:");
    yx = Convert.ToInt32(Console.ReadLine());
    a = yx - 3500;
    

    //计算 if (yx < 3500) { Console.WriteLine("不交个税"); } else { if (a <= 1500) { sl = 0.03; ss = 0; //Console.Write("个税:{0}", gs = a * sl - ss); } else if (a > 1500 && a <= 4500) { sl = 0.1; ss = 105; //Console.Write("个税:{0}", gs = a * sl - ss); } else if (a > 4500 && a <= 9000) { sl = 0.2; ss = 555; //Console.Write("个税:{0}", gs = a * sl - ss); } else if (a > 9000 && a <= 35000) { sl = 0.25; ss = 1005; //Console.Write("个税:{0}", gs = a * sl - ss); } else if (a > 35000 && a <= 55000) { sl = 0.3; ss = 2755; //Console.Write("个税:{0}", gs = a * sl - ss); } else if (a > 55000 && a <= 80000) { sl = 0.35; ss = 5505; //Console.Write("个税:{0}", gs = a * sl - ss); } else { sl = 0.45; ss = 13505; //Console.Write("个税:{0}", gs = a * sl - ss); } } //输出 Console.Write("个税:{0}", gs = a * sl - ss); }

    //案例10 心理测试
    static void Main10(string[] args)
    {
    string dA = "很好!很容易便可以吸引异性。你的幽默感使得人们乐於与你相处,他(她)与你一起时非常快乐!";
    string dB = "恭喜!你对异性有很大的吸引力!在异性的眼中,你有一种魅力。你不只有美丽的外型,而且有幽默和大方的个性。你应该是一个很有气质的人而且深谙与人相处之道,你很懂得支配你的时间,所以你在异性之间很受欢迎。";
    string dC = "哦呜!你并不吸引异性.你并没有十分渊博的知识,也没有什么特别的人格特质.对异性来说,你显得过于粗陋,所以你并不受异性的欢迎.";
    string dD = "尚可!你并不能特别吸引异性,但是你仍然有一些优点,使异性喜欢跟你在一起。你应该是一个很真诚的人,而且对事物有独特的眼光。在你的朋友眼中,你是一个很友善的人。 你的幽默感使得人们乐於与你相处,他(她)与你一起时非常快乐!";
    //输入
    Console.WriteLine("…………心理测试…………");
    Console.WriteLine("凭第一感,做完以下题目,看看你与他(她)的缘分如何");
    Console.WriteLine("现在开始吗?Y/N");
    string a = Console.ReadLine();
    if (a == "Y" || a == "y")
    {
    Console.Clear();
    Console.WriteLine("1.你旅行时,最想去哪个地方?");
    Console.WriteLine("A.北京");
    Console.WriteLine("B.东京");
    Console.WriteLine("C.巴黎");
    string xz1 = Console.ReadLine();
    if (xz1 == "A")
    {
    Console.Clear();
    Console.WriteLine("2.你是否曾在观看感人电影时,泣不成声? A.是 B.否");
    string xz2 = Console.ReadLine();
    if (xz2 == "A")
    {
    Console.Clear();
    Console.WriteLine("4.你喜欢自己一个人去看电影吗? A.是 B.否");
    string xz4 = Console.ReadLine();
    if (xz4 == "A")
    {//问题5
    Console.Clear();
    Console.WriteLine("5.当他(她)在第一次约会时就要求吻你,你会…? A.拒绝 B.轻吻他(她)的额头 C接受并吻她(他)");
    string xz5 = Console.ReadLine();
    if (xz5 == "A")
    {//
    Console.Clear();
    Console.WriteLine("6. 你是个有幽默感的人嘛? A.我想是吧 B.大概不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7
    Console.Clear();
    Console.WriteLine("7.你认为你是个称职的领导吗? A.是 B.不");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {
    //9
    Console.Clear();
    Console.WriteLine("9.你曾经拥有一个以上的男女朋友吗? A.是 B.不");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {//
    Console.WriteLine(dB);
    }
    else
    {//
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }

    }
    else if (xz5 == "B")
    {
    Console.Clear();
    Console.WriteLine("7.你认为你是个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    else
    {//问题6
    Console.Clear();
    Console.WriteLine("6.你是个有幽默感的人吗? A.我想是吧 B.大概不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7
    Console.Clear();
    Console.WriteLine("7.你认为你是个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }

    }

    }
    else
    {
    Console.Clear();
    Console.WriteLine("3");
    }

    }
    else if (xz1 == "B")
    {//3
    Console.Clear();
    Console.WriteLine("3.如果你的男(女)朋友约会时迟到一小时还未出现,你会? A.再等30分钟 B.立刻离开 C.一直等他出现");
    string xz3 = Console.ReadLine();
    if (xz3 == "A")
    {//4
    Console.Clear();
    Console.WriteLine("4.你喜欢一个人去看电影吗? A.是 B.不是");
    string xz4 = Console.ReadLine();
    if (xz4 == "A")
    {//5
    Console.Clear();
    Console.WriteLine("5.当他(她)在第一次约会时就要求吻你,你会…? A.拒绝 B.轻吻他(她)的额头 C接受并吻她(他)");
    string xz5 = Console.ReadLine();
    if (xz5 == "A")
    {//6
    Console.Clear();
    Console.WriteLine("6.你是个有幽默感的人吗? A.是 B.不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7 Console.Clear();
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }

    }
    else if (xz5 == "B")
    {//7
    Console.Clear();
    Console.WriteLine("7.你认为你是个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    else
    {//6
    {//6
    Console.Clear();
    Console.WriteLine("6.你是个有幽默感的人吗? A.是 B.不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7 Console.Clear();
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    }
    }
    else if (xz3 == "B")
    {//5Console.Clear();
    Console.WriteLine("5.当他(她)在第一次约会时就要求吻你,你会…? A.拒绝 B.轻吻他(她)的额头 C接受并吻她(他)");
    string xz5 = Console.ReadLine();
    if (xz5 == "A")
    {//6
    Console.Clear();
    Console.WriteLine("6.你是个有幽默感的人吗? A.是 B.不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7 Console.Clear();
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    else if (xz5 == "B")
    {//7
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    else
    {//6
    {//6
    Console.Clear();
    Console.WriteLine("6.你是个有幽默感的人吗? A.是 B.不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7 Console.Clear();
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    }
    }
    else
    {//移至问题4
    Console.Clear();
    Console.WriteLine("4.你喜欢一个人去看电影吗? A.是 B.不是");
    string xz4 = Console.ReadLine();
    if (xz4 == "A")
    {//5
    Console.Clear();
    Console.WriteLine("5.当他(她)在第一次约会时就要求吻你,你会…? A.拒绝 B.轻吻他(她)的额头 C接受并吻她(他)");
    string xz5 = Console.ReadLine();
    if (xz5 == "A")
    {//6
    Console.Clear();
    Console.WriteLine("6.你是个有幽默感的人吗? A.是 B.不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7 Console.Clear();
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    else if (xz5 == "B")
    {//7
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    else
    {//6
    Console.Clear();
    Console.WriteLine("6.你是个有幽默感的人吗? A.是 B.不是");
    string xz6 = Console.ReadLine();
    if (xz6 == "A")
    {//7 Console.Clear();
    Console.WriteLine("7.你认为你是一个称职的领导吗? A.是 B.不是");
    string xz7 = Console.ReadLine();
    if (xz7 == "A")
    {//9
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    }
    else
    {//8
    Console.Clear();
    Console.WriteLine("8.如果可以选择的话,你希望自己的性别是? A.男性B.女性 C无所谓");
    string xz8 = Console.ReadLine();
    if (xz8 == "A")
    {
    Console.Clear();
    Console.WriteLine("9.你曾经同时拥有一个以上的男女朋友吗? A.是 B.否");
    string xz9 = Console.ReadLine();
    if (xz9 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dA);
    }
    }
    else if (xz8 == "B")
    {//10
    Console.Clear();
    Console.WriteLine("10.你认为你聪明吗? A.是B.不");
    string xz10 = Console.ReadLine();
    if (xz10 == "A")
    {
    Console.WriteLine(dB);
    }
    else
    {
    Console.WriteLine(dC);
    }
    }
    else
    {
    Console.WriteLine(dD);
    }
    }
    }
    }
    }
    }

    好学!好学!好学。

    //案例11 闹钟问题
    static void Main11(string[] args)
    {
    #region
    //输入
    Console.WriteLine("现在几点了?");
    int time = Convert.ToInt32(Console.ReadLine());

    //计算
    if (time < 6)
    {
    Console.WriteLine("还早,继续睡");
    }
    else
    {
    Console.WriteLine("今天周几啊?");
    int week = Convert.ToInt32(Console.ReadLine());
    if (week == 2 || week == 5)
    {
    Console.WriteLine("对,今天不上课啊,接着睡吧");
    }
    else
    {
    Console.WriteLine("我晕,晚了,赶快起床啊!!!");
    }
    }
    #endregion
    }

     

  • 相关阅读:
    使用C#替换Word文档里的文字和图片
    《程序员的思维修炼—开发认知潜能的九堂课》—从新手到专家的历程
    从已有数据库表生成Insert语句的小工具
    我的2010
    Sqlite批量插入速度慢的解决方法小计
    分享一个winForm下的Chart控件
    分享一个任务提醒小工具
    SpringBoot+Vue+Echarts实现选择时间范围内数据加载显示柱状图
    Winform中选取指定文件夹并获取其下所有文件
    Vue中JS遍历后台JAVA返回的Map数据,构造对象数组数据格式
  • 原文地址:https://www.cnblogs.com/jinshui/p/5399381.html
Copyright © 2011-2022 走看看