zoukankan      html  css  js  c++  java
  • 问题 D: C#解密出生日期

    题目描述

    使用C#编写一个静态方法。该方法能够根据出生日期,(1)计算此人的年龄;(2)计算从现在到其60周岁期间,总共多少天。

    输入

    一个人的出生日期;

    输出

    第一行,此人的年龄(只按年度计算)
    第二行,此人从现在到其60周岁期间,总共多少天(天数占5位宽度,右对齐)。

    样例输入

    2019-12-4

    样例输出

    0
    21914

    提示

    假定现在的日期是2019年12月 5日

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace 解密出生日期
    {
        class Program
        {
            static void Main(string[] args)
            {
                DateTime birthdate = Convert.ToDateTime(Console.ReadLine());
                DateTime now = Convert.ToDateTime("2019-12-5"); ;
                int age = now.Year - birthdate.Year;
                Console.WriteLine(age < 0 ? 0 : age);
     
                DateTime next = birthdate.AddYears(60);
                TimeSpan sp = next.Subtract(now);
                Console.WriteLine(sp.Days);
                Console.ReadKey();
            }
        }
    }
     
    

      

  • 相关阅读:
    poj1141
    poj1260
    poj1080
    poj1221
    用Microsoft Office SharePoint Designer 2007开发aspx
    在Web Part中使用User Control
    MOSS中的WebPart开发
    在MOSS中开发一个模块化的feature
    SharePoint Web Service的身份验证
    MOSS中对列表的一些操作(创建,查询等)
  • 原文地址:https://www.cnblogs.com/mjn1/p/12523914.html
Copyright © 2011-2022 走看看