本文向给大家分享年月号黄历查询结果相关知识,同时小编也会对年月日黄历查询进行解释,如果能解决您在年月号黄历查询结果方面面临的问题,请收藏关注本站,现在开始吧!
万年历查询程序
你试试这个,不过没有农历节气和农历年月日
using System;
using System.Collections.Generic;
using System.Text;
namespace Year
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("*************************欢迎使用万年历*************************\n\n");
Console.Write("请选择年份:\t");
int year = int.Parse(Console.ReadLine());
Console.Write("\n请选择月份\t");
int month = int.Parse(Console.ReadLine());
bool w;
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
w = true;
}
else
{
w = false;
}
int day = 0;
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day = 31;
break;
case 4:
case 6:
case 9:
case 11:
day = 30;
break;
case 2:
if (w == true)
{
day = 29;
}
else
{
day = 28;
}
break;
}
int b = 0;
for (int i = 1900; i < year; i++)
{
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)
{
b = b + 366;
}
else
{
b = b + 365;
}
}
for (int i = 1; i < month; i++)
{
switch (i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
b = b + 31;
break;
case 4:
case 6:
case 9:
case 11:
b = b + 30;
break;
case 2:
if (w == true)
{
b = b + 29;
}
else
{
b = b + 28;
}
break;
}
}
int fristDayOfMonth = 1 + b % 7;
if (fristDayOfMonth == 7)
{
fristDayOfMonth = 0;
}
Console.WriteLine("\n\n星期日\t星期一\t星期二\t星期三\t星期四\t星期五\t星期六");
for (int i = 0; i < fristDayOfMonth; i++)
{
Console.Write("\t");
}
for (int i = 1; i <= day; i++)
{
Console.Write("{0}\t",i);
if ((fristDayOfMonth + i) % 7 == 0)
{
Console.WriteLine();
}
}
Console.ReadLine();
}
}
}
以上就是与年月号黄历查询结果以及年月日黄历查询的相关内容,也是关于万年历查询程序的分享。看完年月号黄历查询结果一文后,希望这对大家有所帮助!