#include<stdio.h>
int main()
{
int year=0, month=0, day=0, y=0, m=0;
scanf_s("%d %d", &year,&month);
//判断闰年
for(y=1900;y<year;y++)
{
if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
day += 366;
else
day += 365;
}
//月份
for(m=1;m<month;m++)
{
switch (m)
{
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 ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
day += 29; break;
}
else
{
day += 28; break;
}
}
}
int n ;
if (day % 7 != 6) n = day % 7 + 1;
else n = 0;
int count=n ,h,g;
switch (month)
{
case 1:case 3:case 5:case 7:case 8:case 10:case 12: h = 31; break;
case 4:case 6:case 9:case 11:h = 30; break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
h = 29; break;
}
else
{
h = 28; break;
}
}
//与1900年差几天,打印空格
printf("日\t一\t二\t三\t四\t五\t六\n");
//打印天数
int a = 0 ,b= 0;
for (a = 1; a <= count; a++)
printf("\t");
for (g = 1; g <= h; g++)
{
printf("%d", g);
printf("\t");
if (g + count == 7)
{
printf("\n");
goto add;
}
}
add:
for (b = 0,g++; g <= h; g++)
{
printf("%d", g);
printf("\t");
b++;
if (b == 7)
{
b = 0;
printf("\n");
}
}
printf("\n");
return 0;
}