码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-03-28 15:45:16      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

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();
            }

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

标签:

原文地址:http://www.cnblogs.com/lk-kk/p/4374271.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!