黑马程序员 C#程序 求你活了多少天

---------------------- android培训java培训、期待与您交流! ----------------------

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

namespace buxinga
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("请输入出生日期:(形式2012 2 3)");
                string date = Console.ReadLine();
                DateTime s;
                DateTime.TryParse(date, out s);
                //  Console.WriteLine(s);
                int c = Convert.ToInt32(s.DayOfYear);
                //Console.WriteLine(c);
                int year = Convert.ToInt32(s.Year);
                // Console.WriteLine(year );
int b = Convert.ToInt32(DateTime.Now.Year);
                // Console.WriteLine(b);
                int a = Convert.ToInt32(DateTime.Now.DayOfYear);
                // Console.WriteLine(a);
                int x = 0;
                int y = 0;
                int tianshu;
                if (year < b)
                {
                    while (year < b)
                    {
                        if (DateTime.IsLeapYear(year))
                        { x++; }
                        else { y++; }
                        year++;
                    }
                    tianshu = a - c + x * 366 + y * 365;
                    goto zhengque;
                }
                else
                {
                    if (year == b)
                    {
                        tianshu = a - c;
                        goto zhengque;
                    }
                    else
                    { goto cuowu; }
                }
            zhengque:
                {
                    Console.WriteLine(tianshu);
                    continue;
                }
            cuowu:
                {
                    Console.WriteLine("输入错误请重新输入!");
                }
            }
        }
    }
}

 

---------------------- android培训java培训、期待与您交流! ----------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值