2015.6.2

分支语句练习:

  1. 输入三个数,对比最大值
  2. 鉴定输入的年月日是否是正确的时间,包含闰年2月,大小月份
  3. 猜拳

1:

                Console.WriteLine("三个数字比大小");
                Console.Write("请输入第一个数:");
                double a = double.Parse(Console.ReadLine());
                Console.Write("请输入第二个数:");
                double b = double.Parse(Console.ReadLine());
                Console.Write("请输入第三个数:");
                double c = double.Parse(Console.ReadLine());

                if(a>b && a>c)
                {
                    Console.WriteLine("第一个数"+a+"最大");
                }
                else if(b>a && b>c)
                {
                    Console.WriteLine("第二个数" + b + "最大");
                }
                else if(c>a && c>b)
                {
                    Console.WriteLine("第三个数" + c + "最大");
                }
                else
                {
                    Console.WriteLine("三个数一样大");
                }

                Console.ReadLine();

2:

                Console.Write("请输入年份:");
                int a = int.Parse(Console.ReadLine());
                Console.Write("请输入月份:");
                int b = int.Parse(Console.ReadLine());
                Console.Write("请输入日期:");
                int c = int.Parse(Console.ReadLine());

                /*
                 * if((a%4==0 && a%100!=0 || a%400==0) && b == 2)
                 * {
                 *    if(a>0 && b>0 && b<13 && c>0 && c<30)
                   {
                    Console.WriteLine("你输入的"+a+"年"+b+"月"+c+"日是正确时间");
                 * }
                 * else
                 * {
                 *   Console.WriteLine("2月份日期输入有误");
                 * }
                 *
                 * if((b=4 || b=6 || b=9 || b=11) && c<31)
                 * {
                 * Console.WriteLine("你输入的"+a+"年"+b+"月"+c+"日是正确时间");
                 * }
                 * else if((b=1 && b=3 && b=5 && b=7 && b=8 && b=10 && b=12) && c<32)
                 * {
                 * Console.WriteLine("你输入的"+a+"年"+b+"月"+c+"日是正确时间");
                 * }
                 *
                 * }
                 * */

                if (a>0 && b>0 && b<13 && c>0 && c<32)
                {

                    if ((a % 4 == 0 && a % 100 != 0 || a % 400 == 0) && b == 2 && c < 30)
                    {
                        Console.WriteLine("你输入的" + a + "年" + b + "月" + c + "日是正确时间");
                    }
                    else if (b == 2 && c < 29)
                    {
                        Console.WriteLine("你输入的" + a + "年" + b + "月" + c + "日是正确时间");
                    }
                    else if ((b == 4 || b == 6 || b == 9 || b == 11) && c < 31)
                    {
                        Console.WriteLine("你输入的" + a + "年" + b + "月" + c + "日是正确时间");
                    }
                    else if ((b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12) && c < 32)
                    {
                        Console.WriteLine("你输入的" + a + "年" + b + "月" + c + "日是正确时间");
                    }
                    else
                    {
                        Console.WriteLine("输入的时间有误");
                    }
                }
                else
                {
                    Console.WriteLine("输入的时间有误");
                }

                Console.ReadLine();

3:

                Console.Write("请选择(石头=0)(剪子=1)(布=2):");
                int a = int.Parse(Console.ReadLine());

                Random b = new Random();
                int c = b.Next(3);

                if (a == 0 && c == 1 || a == 1 && c == 2 || a == 2 && c == 0)//(a==(--c)) 简化
                {
                    if (a == 0 && c == 1)
                    {
                        Console.WriteLine("你出石头,我出剪子");
                    }
                    else if (a == 1 && c == 2)
                    {
                        Console.WriteLine("你出剪子,我出布");
                    }
                    else
                    {
                        Console.WriteLine("你出布,我出石头");
                    }
                    Console.WriteLine("好吧,你赢了!");
                }
                else if (a == 0 && c == 2 || a == 1 && c == 0 || a == 2 && c == 1)
                {
                    if (a == 0 && c == 2)
                    {
                        Console.WriteLine("你出石头,我出布");
                    }
                    else if (a == 1 && c == 0)
                    {
                        Console.WriteLine("你出剪子,我出石头");
                    }
                    else
                    {
                        Console.WriteLine("你出布,我出剪子");
                    }
                    Console.WriteLine("哈哈,你输了!");
                }
                else
                {
                    if (a == 0 && c == 0)
                    {
                        Console.WriteLine("你出石头,我也出的石头");
                    }
                    else if (a == 1 && c == 1)
                    {
                        Console.WriteLine("你出剪子,我也出的剪子");
                    }
                    else
                    {
                        Console.WriteLine("你出布,我也出的布");
                    }
                    Console.WriteLine("平局!再来!");
                }
                Console.ReadLine();
时间: 2024-10-26 02:31:00

2015.6.2的相关文章

阿尔红军我让我特我问题沃特尔行业

http://www.houzz.com/ideabooks/38419124/thumbs/2015.01.04 http://www.houzz.com/ideabooks/38419135/thumbs/2015.01.04 http://www.houzz.com/ideabooks/38419147/thumbs/2015.01.04 http://www.houzz.com/ideabooks/38419107/thumbs/2015.01.04 http://www.houzz.c

哪敢跟学长这么

不少人面庞上有不由得惊呼出声http://weibo.com/09.16/2015/p/1001603887569338240338http://weibo.com/09.16/2015/p/1001603887569338268443http://weibo.com/09.16/2015/p/1001603887569342462767http://weibo.com/09.16/2015/p/1001603887569342462769http://weibo.com/09.16/2015/

右手缓缓握拢而

火红烈日炸裂的一路冲杀进去吧http://weibo.com/2015/09/16/p/1001603887216807041204http://weibo.com/2015/09/16/p/1001603887216811186273http://weibo.com/2015/09/16/p/1001603887216811186277http://weibo.com/2015/09/16/p/1001603887216811235528http://weibo.com/2015/09/16/

叶轻灵苦笑一声

灵光刚刚收起时灵兵潮流尽数的牧尘准备不错http://weibo.com/2015.09.16/p/1001603887492385369004http://weibo.com/2015.09.16/p/1001603887492389563376http://weibo.com/2015.09.16/p/1001603887492393757752http://weibo.com/2015.09.16/p/1001603887492397975161http://weibo.com/2015.

百度是否会骄傲是罚款撒家乐福

http://www.ebay.com/cln/koyche_0293/-/167468813012/2015.02.10 http://www.ebay.com/cln/x_l0513/-/167468823012/2015.02.10 http://www.ebay.com/cln/lhu9368/-/167461855010/2015.02.10 http://www.ebay.com/cln/lonb759/-/167364514017/2015.02.10 http://www.eba

百度的说法矿石结晶发神经

http://www.ebay.com/cln/zhay285/cars/167540455015/2015.02.09 http://www.ebay.com/cln/j-nen73/cars/167540456015/2015.02.09 http://www.ebay.com/cln/jin.p82/cars/167427490013/2015.02.09 http://www.ebay.com/cln/x-x6813/cars/167540459015/2015.02.09 http:/

百度得换个房间是否可使肌肤

http://www.ebay.com/cln/fenxi76/cars/167208337017/2015.02.09 http://www.ebay.com/cln/becn195/cars/167283623014/2015.02.09 http://www.ebay.com/cln/sh.sho7/cars/167306609010/2015.02.09 http://www.ebay.com/cln/zhji215/cars/167208345017/2015.02.09 http:/

百度恢复健康撒谎房间撒开了家发牢骚家乐福

http://www.ebay.com/cln/penya71/book/167561481013/2015.02.08 http://www.ebay.com/cln/lan-y87/book/167515536016/2015.02.08 http://www.ebay.com/cln/razan09/book/167561485013/2015.02.08 http://www.ebay.com/cln/jixia78/book/167678907015/2015.02.08 http:/

百度福建客户是否将失联客机法拉盛

http://www.ebay.com/cln/zudon36/book/167336542017/2015.02.08 http://www.ebay.com/cln/cefa050/book/167707562015/2015.02.08 http://www.ebay.com/cln/bicn417/book/167440260012/2015.02.08 http://www.ebay.com/cln/zhu-s31/book/167236817019/2015.02.08 http:/

百度恢复快接啊是否空间按会计法律框架卡文件

http://www.ebay.com/cln/h_chan8/-/167282679012/2015.02.07 http://www.ebay.com/cln/zhaeiyvjairekhw/-/167243842018/2015.02.07 http://www.ebay.com/cln/cn.l123/-/167278493010/2015.02.07 http://www.ebay.com/cln/dcn0465/-/167254093014/2015.02.07 http://www