• 利用switch case 来运行咱们结婚吧


    static void Main(string[] args)
            {
                while (true)
                {
                    int x, y,z; string a, b,c;
                    Random r=new Random();                       //这个是用的随机数随机生成,并且利用switch case赋予x,y,z成为"剪刀"石头""布""的含义。
                    x = r.Next(0, 2);                                     //注意switch case 要与break连用。
                    y = r.Next(0, 2);
                    z = r.Next(0, 2);
                    switch (x)
                    {
                        case 0:
                            a = "有房";
                            break;
                        case 1:
                            a = "没房";
                            break;
                        default:
                            a = "康康";
                            break;
                    }
                    switch (y)
                    {
                        case 0:
                            b = "有车";
                            break;
                        case 1:
                            b = "没车";
                            break;
                        default:
                            b = "康康";
                            break;
                    }
                    switch (z)
                    {
                        case 0:
                            c = "有钱";
                            break;
                        case 1:
                            c = "没钱";
                            break;
                        default:
                            c = "康康";
                            break;
                    }
                    Console.WriteLine(a);
                    Console.WriteLine(b);
                    Console.WriteLine(c);
                    if (x == 0 && y == 0 & z == 0)
                    {
                        Console.WriteLine("来结婚吧!!");
                    }

                     else if (x == 0 && y == 1 & z == 1)
                        {
                            Console.WriteLine("车钱都没有,等你有实力买了车再来把");
                        }
                     else if (x == 0 && y == 0 & z == 1)
                        {
                            Console.WriteLine("没钱跟着你喝西北风啊!!");
                        }
                     else if (x == 1 && y == 0 & z == 1)
                        {
                            Console.WriteLine("买了房子再说不然住车上吗");
                        }
                        else if (x == 0 && y == 1 & z == 0)
                        {
                            Console.WriteLine("上班想让我坐公交是不是?");
                        }
                    else if (x == 1 && y == 0 & z == 0)
                    {
                        Console.WriteLine("没房住哪儿");
                    }
                       else
                       {
                        Console.WriteLine("下一个");
                       }

                  
                   
                   
                   
                   
                   
                    Console.ReadLine();
                }

  • 相关阅读:
    C# 使用Dev控件为gridView添加复选框,实现多选和单选
    C# 关于LINQ基础随笔
    Camstar客制化开发做查询操作(Designer中存放SQL语句)
    ASP.NET 实现自动登录(自定义自动登录时间期限)
    ASP.NET 页面生命周期-动态控件编程(动态添加控件并使用动态控件值)
    Camstar客制化开发查询数据库数据并显示在JQDataGrid表中(SQL语句编写在UserQuery中)同时获取JQDataGrid中值回传到Designer中
    Camstar客制化开发查询数据库数据并显示在JQDataGrid表中(SQL语句编写在代码中)
    WPF开发中常用的几种布局元素
    Cocos2dx 内存管理机制(1)
    cocos2dx 坐标系统详解
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4374271.html
Copyright © 2020-2023  润新知