• 24小时制转化为12小时制(if语句简单练习)


    namespace ConsoleApplication18
    {
        class Program
        {
            static void Main(string[] args)
            {
                while (true)
                {
                    int t,n;
                Console.Write("请输入24小时制时间:");
                t = Convert.ToInt32(Console.ReadLine());
                if (t>0&&t<6)
                {
                   Console.WriteLine("现在时间是凌晨:"+t+"");  
                }
                else if (t==0||t==24)
                {
                   
                    Console.WriteLine("现在时间是凌晨:0时");
    
                }
                else if (t >=6 && t <= 12)
                {
    
                    Console.WriteLine("现在时间是上午:" + t + "");
                }
                else if (t > 12 && t <= 18)
                {
                    n = t - 12;
                    Console.WriteLine("现在时间是下午:" + n + "");
    
                }
                else if (t>12&&t<=18)
                {
                    n = t - 12;
                    Console.WriteLine("现在时间是下午:" + n+"");
      
                }
                else if (t >18 && t <= 23)
                {
                    n = t - 12;
                    Console.WriteLine("现在时间是晚上:" + n + "");
    
                }
             
                else
                {
                    Console.WriteLine("请输入正确的时间!" );
                }
                }
                
            }
        }
    }
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    linux日常。
    tp5中的config类和config助手函数
    TP5隐藏index.php
    TP5读取数据概述
    TP5的安装部署概要
    eclipse4.7中文包安装方法。
    利用mysqldump备份magento数据库
    MySQL 基础知识
    PHP 基础知识
    妖怪与和尚过河问题
  • 原文地址:https://www.cnblogs.com/dlexia/p/4373603.html
Copyright © 2020-2023  润新知