zoukankan      html  css  js  c++  java
  • 条件语句实例

    判断三个数谁对大:

    static void Main(string[] args)
            {
                Console.WriteLine("请输入第一个数:");
                int a = Convert.ToInt32(Console.ReadLine());
    
                Console.WriteLine("请输入第二个数:");
                int b = Convert.ToInt32(Console.ReadLine());
    
                Console.WriteLine("请输入第三个数:");
                int c = Convert.ToInt32(Console.ReadLine());
    
    
                if (a >= b)
                {
                    if (a >= c)
                    {
                        Console.WriteLine("三个数最大的是:" + a);
                    }
    
                    else
                    {
                        Console.WriteLine("三个数最大的是:" + c);
    
                    }
    
                }
                else
                {
    
                    if (b >= c)
                    {
                        Console.WriteLine("三个数最大的是" + b);
    
                    }
    
                    else
                    {
                        Console.WriteLine("三个数最大的是" + c);
                    }
                }
    
    
            }

    判断一个数的奇偶性:

     static void Main(string[] args)
            {
                Console.Write("输入一个数:");
                int a = int.Parse(Console.ReadLine());
               
                if (a%2== 0)
                {
                    Console.Write("这个数是偶数");
                }
                else 
                {
                    Console.Write("这个数是奇数");
                }
                Console.ReadLine();
               
            }  

    判断闰年:

    static void Main(string[] args)
            {
                Console.WriteLine("请输入年份:");
                int year = int.Parse(Console.ReadLine());
                if (year % 400 == 0 || year % 4 == 0 && year % 4 != 0)
                {
                    Console.Write(year + "是闰年");
    
                }
                else 
                {
                    Console.Write(year+"是平年");
                }
            }

    移动客服:

    static void Main(string[] args)
    {
    Console.WriteLine("查话费按1,查流量按2,人工服务按3,业务办理按4,");
    int a = Convert.ToInt32(Console.ReadLine());
    
    
    switch (a)
    {
    case 1:
    {
    Console.WriteLine("你的话费有点多,禁止充值");
    break;
    }
    case 2:
    {
    Console.WriteLine("流量还可以支撑");
    break;
    }
    case 3:
    {
    Console.WriteLine("人工服务全忙,请稍候");
    break;
    }
    
    case 4:
    {
    Console.WriteLine("对不起不能办理");
    break;
    }
    default:
    {
    Console.WriteLine("您输入的有误");
    break;
    }
    
    
    }
    }

    游戏随即英雄选择:

     static void Main(string[] args)
            {
                Random a = new Random();
                int b = a.Next(5);
    
                string hero;
    
                switch (b)
                {
                    case 1:
                        {
                            hero = "伊泽瑞尔";
                            break;
                        }
    
                    case 2:
                        {
                            hero = "拉克丝";
                            break;
                        }
    
                    case 3:
                        {
                            hero = "盖伦";
                            break;
                        }
    
                    case 4:
                        {
                            hero = "提莫";
                            break;
                        }
    
                    default:
                        {
                            hero = "崔丝塔娜";
                            break;
                        }
                }
    
                Console.WriteLine("你选的英雄为:" + hero + ",请做好开始准备");
                
            }
  • 相关阅读:
    centos 6.5 查看、开启,关闭 端口
    centos 安装 nginx
    centos 安装 svn
    centos 安装 maven
    (转)不停止Nginx服务的情况下平滑变更Nginx配置
    记录1---python+linux+vim之while循环语句使用
    记录1---linux系统之创建用户,用户登录,查看用户名,切换用户登录,退出登录
    记录——Fiddler5.0 中文版 绿色免费版 汉化破解版安装
    fiddler笔记1---fiddler的安装 和 证书安装 以及 证书导出失败问题解决
    fiddler笔记2--fiddler工具界面的功能使用与介绍
  • 原文地址:https://www.cnblogs.com/liuyudong0825/p/4696672.html
Copyright © 2011-2022 走看看