4.27语句.剪刀石头布练习

Console.Write

 int yh = Convert.ToInt32(Console.ReadLine());

 

       Random r = new Random();

                int dn = r.Next(0, 3);

 

                //3、对比,输出结果

                //石头0,剪子1,布2

                //0 1 = -1

                //1 2 = -1

                //2 0 = 2

 

                //0 2 = -2

                //1 0 = 1

                //2 1 = 1

                int jg = yh - dn;

                if (jg == -1 || jg == 2)

                {

                    Console.WriteLine("用户胜利!");

                }

                else if (jg == -2 || jg == 1)

                {

                    Console.WriteLine("用户失败!");

                }

                else

                {

                    Console.WriteLine("平局!");

                }

            }

            Console.ReadLine();

posted @ 2016-05-03 12:39  一人饮酒醉(SeVen❤)  阅读(145)  评论(0编辑  收藏  举报