zoukankan      html  css  js  c++  java
  • 输入某人出生日期(以字符串方式输入,如1987-4-1)使用DateTime和TimeSpan类,(1)计算其人的年龄;(2)计算从现在到其60周岁期间,总共多少天。

    http://blog.csdn.net/w92a01n19g/article/details/8764116

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

    namespace ConsoleApplication5
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("请输入出生年份");
                string n = Console.ReadLine();
                int n1;
                int.TryParse(n, out n1);
                Console.WriteLine("请输入出生yue份");
                string y = Console.ReadLine();
                int y1;
                int.TryParse(y, out y1);
                Console.WriteLine("请输入出生日子");
                string r = Console.ReadLine();
                int r1;
                int.TryParse(r, out r1);
                DateTime dt = new DateTime(n1,y1,r1);
                Console.WriteLine(dt.ToShortDateString ());
                int nl = DateTime.Now.Year - n1;
                Console.WriteLine("他的年龄是{0}",nl);
                DateTime dt1 = new DateTime(n1+60, y1, r1);
                TimeSpan ts = dt1 - DateTime.Now;
                Console.WriteLine("从现在到其60周岁期间,总共{0}天",ts.Days.ToString ());
            }
        }
    }

  • 相关阅读:
    cuda thrust函数首次调用耗费时间比后续调用长原因
    poj2823/hdu3415
    hiho1515
    hiho147周
    hdu1864/2844/2159 背包基础题
    qt + opencv
    Matlab函数编译成dll供c调用
    无处不在的编程思想
    五步使用法——搞定XMLHttpRequest
    AJAX与传统Web开发比较
  • 原文地址:https://www.cnblogs.com/Echo529/p/6382340.html
Copyright © 2011-2022 走看看