• 判断是今年的第几天


    switch case的用法:

    switch(括号内为对应执行case类似代号):例 switch(1)则执行case 1 语句

    执行完case则break跳出!

    判断是今年的第几天:

    namespace ConsoleApplication11
    {
        class Program
        {
            static void Main(string[] args)
            {
                while (true)
                {
                    int m1 = 31, m2 = 28, m3 = 31, m4 = 30, m5 = 31, m6 = 30, m7 = 31, m8 = 31, m9 = 30, m10 = 31, m11 = 30;
                Console.Write("请输入月份:");
                int m = Convert.ToInt32(Console.ReadLine());
                Console.Write("请输入几号:");
                int d = Convert.ToInt32(Console.ReadLine());
                switch (m)
                {
                    case 1:
                        Console.WriteLine(""+d.ToString()+"");
                        break;//跳出语句
                    case 2:
                        Console.WriteLine("" + (m1+d).ToString() + "");
                        break;
                    case 3:
                        Console.WriteLine("" + (m1+m2 + d).ToString() + "");
                        break;
                    case 4:
                        Console.WriteLine("" + (m1+m2+m3 + d).ToString() + "");
                        break;
                    case 5:
                        Console.WriteLine("" + (m1 + m2 + m3+m4 + d).ToString() + "");
                        break;
                    case 6:
                        Console.WriteLine("" + (m1 + m2 + m3 + m4+m5+ d).ToString() + "");
                        break;
                    case 7:
                        Console.WriteLine("" + (m1 + m2 + m3 + m4 +m5+m6+ d).ToString() + "");
                        break;
                    case 8:
                        Console.WriteLine("" + (m1 + m2 + m3 + m4 + m5 + m6 +m7+ d).ToString() + "");
                        break;
                    case 9:
                        Console.WriteLine("" + (m1 + m2 + m3 + m4 +m5+ m6 +m7+m8+d).ToString() + "");
                        break;
                    case 10:
                        Console.WriteLine("" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8+m9 + d).ToString() + "");
                        break;
                    case 11:
                        Console.WriteLine("" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 +m10+ d).ToString() + "");
                        break;
                    case 12:
                        Console.WriteLine("" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 +m10+m11+ d).ToString() + "");
                        break;
                    default:
                        Console.WriteLine("您的输入有误:");
                        break;
    
                }
                }
                
    
    
            }
        }
    }
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    spring配置初始化出错
    Java常用工具类(计算MD5,验证码随机生成,天数差值计算)
    Java基础(静态static)
    websocket使用nginx代理后连接频繁打开和关闭
    关于kafka客户端版本与服务端版本不一致导致的一次坑
    kafka
    maven常用命令含义
    pg数据库org.postgresql.util.PSQLException: ERROR: "xxx" is not a sequence
    @Param注解和@Mapper注解
    springmvc对参数接收的两个注解@RequestParam和@RequestBody
  • 原文地址:https://www.cnblogs.com/dlexia/p/4371803.html
Copyright © 2020-2023  润新知