【C#编写控制台程序根据年月日计算当天是本年的第几天】2022-12-3
·
缘由编写控制台程序,根据年月日计算当天是本年的第几天-编程语言-CSDN问答
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C井控制台
{
class Program
{
public static int 返回月的天数(int 年, int 月)
{//缘由https://ask.csdn.net/questions/7851031
return (月 == 2 ?
(((年 % 4 == 0 && 年 % 100 > 0) || 年 % 400 == 0) ? 29 : 28) :
(((月 <= 7 && 月 % 2 > 0) || (月 > 7 && 月 % 2 == 0)) ? 31 : 30));
}
static void Main(string[] args)
{
int n = 0, y = 0, t = 0;
n = int.Parse(Console.ReadLine());
y = int.Parse(Console.ReadLine());
t = int.Parse(Console.ReadLine());
js: if (--y > 0) { t += 返回月的天数(n, y); goto js; }
Console.WriteLine("是当年天数:{0}",t);
Console.ReadKey();
}
}
}

更多推荐
所有评论(0)