using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { while (true) { Console.Write("请输入年"); int year = int.Parse(Console.ReadLine()); Console.Write("请输入月"); int mouth = int.Parse(Console.ReadLine()); Console.Write("请输入日"); int day = int.Parse(Console.ReadLine()); if (mouth == 1 &&( year > 1795 && year < 9999) &&( day > 0 && day <= 31)) { Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", day); } else if ((year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) &&( year > 1795 && year < 9999 )&&( mouth > 0 && mouth <= 12) && (day > 0 && day <= 31)) { if (mouth == 2 && day <= 29) { int m = 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 3 && day <= 31) { int m = 31 + 29 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 4 && day <= 30) { int m = 31 + 29 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 5 && day <= 31) { int m = 31 + 29 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 6 && day <= 30) { int m = 31 + 29 + 31 + 30 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 7 && day <= 31) { int m = 31 + 29 + 31 + 30 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 8 && day <= 30) { int m = 31 + 29 + 31 + 30 + 31 + 30 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 9 && day <= 31) { int m = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 10 && day <= 31) { int m = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 11 && day <= 30) { int m = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 12 && day <= 31) { int m = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } } else if ((year > 1795 && year < 9999) &&( mouth > 0 && mouth <= 12) && (day > 0 && day <= 31)) { if (mouth == 2 && day <= 28) { int m = 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 3 && day <= 31) { int m = 31 + 28 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 4 && day <= 30) { int m = 31 + 28 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 5 && day <= 31) { int m = 31 + 28 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 6 && day <= 30) { int m = 31 + 28 + 31 + 30 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 7 && day <= 31) { int m = 31 + 28 + 31 + 30 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 8 && day <= 30) { int m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 9 && day <= 31) { int m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 10 && day <= 31) { int m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 11 && day <= 30) { int m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } else if (mouth == 12 && day <= 31) { int m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day; Console.WriteLine(year.ToString() + "年" + mouth.ToString() + "月" + day.ToString() + "日" + "是这一年的第{0}天", m); } } else { Console.WriteLine("请输入正确的年月日"); } Console.ReadLine(); } } } }
时间: 2024-11-05 21:37:58