using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int year, month;
List<string> s = new List<string>();
int yearofDays = 0;
int monthofDays = 0;
while (true)
{
while (true)
{
Console.Write("请输入年份(1990——2100):");
year = int.Parse(Console.ReadLine());
if (year < 1990)
{
Console.WriteLine("年份错误,请按回车键继续!");
Console.ReadLine();
Console.Clear();
}
else
{
Console.Write("请输入月份(1-12):");
month = int.Parse(Console.ReadLine());
if (month <= 0 || month > 12)
{
Console.WriteLine("月份错误,请按回车继续!");
Console.ReadLine();
Console.Clear();
}
else
{
break;
}
}
}
#endregion
#region 1990年到year-1年总共的天数
for (int i = 1990; i < year; i++)
{
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)
{
yearofDays += 366;
{
yearofDays += 365;
}
}
#endregion
#region year年1月到month-1月总共的天数
for (int j = 1; j < month; j++)
{
if (j == 2)
{
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
monthofDays += 29;
}
else
{
monthofDays += 28;
}
}
else if (j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 || j == 12)
{
monthofDays += 31;
}
else
{
monthofDays += 30;
}
}
int AllDays = yearofDays + monthofDays;
int dayofWeek = AllDays % 7 + 1;
int space = dayofWeek - 1;
for (int k = 0; k < space; k++)
{
s.Add("");
}
int days = 0
if (month == 2)
{
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
days = 29;
}
else
{
days = 28;
}
}
else if (month <= 7 && month % 2 != 0 || month > 7 && month % 2 == 0)
{
days = 31;
}
else
{
days = 30;
}
for (int y = 1; y <= days; y++)
{
s.Add(y.ToString());
}
Console.WriteLine("*****************************************************");
Console.Write("一\t二\t三\t四\t五\t六\t七");
for (int m = 0; m < s.Count; m++)
{
if (m % 7 == 0)
{
Console.WriteLine();
}
Console.Write(s[m] + "\t");
}
Console.WriteLine();
Console.WriteLine("******************************************************");
Console.WriteLine("按任意键继续");
Console.ReadLine();
Console.Clear();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int year, month;
List<string> s = new List<string>();
int yearofDays = 0;
int monthofDays = 0;
while (true)
{
while (true)
{
Console.Write("请输入年份(1990——2100):");
year = int.Parse(Console.ReadLine());
if (year < 1990)
{
Console.WriteLine("年份错误,请按回车键继续!");
Console.ReadLine();
Console.Clear();
}
else
{
Console.Write("请输入月份(1-12):");
month = int.Parse(Console.ReadLine());
if (month <= 0 || month > 12)
{
Console.WriteLine("月份错误,请按回车继续!");
Console.ReadLine();
Console.Clear();
}
else
{
break;
}
}
}
#endregion
#region 1990年到year-1年总共的天数
for (int i = 1990; i < year; i++)
{
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)
{
yearofDays += 366;
}
else
{
yearofDays += 365;
}
}
#endregion
#region year年1月到month-1月总共的天数
for (int j = 1; j < month; j++)
{
if (j == 2)
{
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
monthofDays += 29;
}
else
{
monthofDays += 28;
}
}
else if (j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 || j == 12)
{
monthofDays += 31;
}
else
{
monthofDays += 30;
}
}
int AllDays = yearofDays + monthofDays;
int dayofWeek = AllDays % 7 + 1;
int space = dayofWeek - 1;
for (int k = 0; k < space; k++)
{
s.Add("");
}
int days = 0
if (month == 2)
{
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
days = 29;
}
else
{
days = 28;
}
}
else if (month <= 7 && month % 2 != 0 || month > 7 && month % 2 == 0)
{
days = 31;
}
else
{
days = 30;
}
for (int y = 1; y <= days; y++)
{
s.Add(y.ToString());
}
Console.WriteLine("*****************************************************");
Console.Write("一\t二\t三\t四\t五\t六\t七");
for (int m = 0; m < s.Count; m++)
{
if (m % 7 == 0)
{
Console.WriteLine();
}
Console.Write(s[m] + "\t");
}
Console.WriteLine();
Console.WriteLine("******************************************************");
Console.WriteLine("按任意键继续");
Console.ReadLine();
Console.Clear();
}
}
}
}