zoukankan      html  css  js  c++  java
  • c#条件运算符的使用,判断时间是上午还是下午

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace _4
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.Write("请输入时间:");
                int t = int.Parse(Console.ReadLine());
                if (t >= 0 && t < 24)
                {
                    string a = (t > 12) ? "pm" : "am";
                    t = t > 12 ? t - 12 : t;
                    Console.WriteLine("现在是" + t + a);
                }
                else
                {
                    Console.WriteLine("您输入的时间有误,请重新输入!");
                }
                Console.ReadLine();

            }
        }
    }

  • 相关阅读:
    Linux Screen
    python SQLAlchemy 学习
    python Django 分页功能
    大数据 HBase Shell
    HBase 表操作
    Nginx 编译安装
    python Django 发送邮件
    python Django 用户管理和权限认证
    python shutil 文件操作
    python zip 压缩文件
  • 原文地址:https://www.cnblogs.com/jiang2538406936/p/5192733.html
Copyright © 2011-2022 走看看