---------------------- 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("输入错误请重新输入!");
}
}
}
}
}
{
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培训、期待与您交流! ----------------------