Archived
1
0
This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SomeLab/CS/lab10/10_3/Program.cs
2026-03-19 19:39:01 +08:00

33 lines
1.0 KiB
C#

namespace _10_3
{
internal class Program
{
static void Main(string[] args)
{
const string s4 = " ";
int nYear = DateTime.Today.Year;
for (int nMonth = 1; nMonth <= 12; nMonth++)
{
DateTime d1 = new DateTime(nYear, nMonth, 1);
Console.WriteLine("{0}/{1}", d1.Year, d1.Month);
Console.WriteLine("Su Mo Tu We Th Fr Sa");
int iWeeks = (int)d1.DayOfWeek;
int iLastDay = d1.AddMonths(1).AddDays(-1).Day;
for (int i = 0; i < iWeeks; i++)
{
Console.Write(s4);
}
for (int iDay = 1; iDay <= iLastDay; iDay++)
{
Console.Write(" {0:00} ", iDay);
if ((iDay + iWeeks) % 7 == 0)
{
Console.WriteLine();
}
}
Console.WriteLine();
}
}
}
}