//
// main.cpp
// Calender
//
// Created by 김 태진 on 12. 1. 10..
// Copyright (c) 2012년 __MyCompanyName__. All rights reserved.
//
#include <stdio.h>
int isLeapYr(int yr);
int isThirtyOne(int mth);
int main()
{
int month,day=1,myYear,date=1,monthEndDate;
int i;
int Max;
scanf("%d",&myYear);
if(isLeapYr(myYear)==1){
Max=366;
}else{
Max=365;
}
for(i=1;i<myYear;i++){
if(isLeapYr(i-1)==1&&i!=1){
day+=2;
}else{
day++;
}
//day 0 == 일
}
day%=7;
for(month=1;month<=12;month++){
date=1;
if(isThirtyOne(month)==1){
monthEndDate=31;
}else{
monthEndDate=30;
if(month==2){
monthEndDate=28;
if(isLeapYr(myYear)==1){
monthEndDate=29;
}
}
}
printf("\n%d월\n",month);//몇월
printf("일\t월\t화\t수\t목\t금\t토\n");
for(i=0;i<day;i++){
printf("\t");
}
for(;date<=monthEndDate;date++){
printf("%d\t",date);
if(i%7==6){
printf("\n");
}
i++;
}
day=i%7;
}
return 0;
}
int isLeapYr(int yr){
int flag=0;
if(yr%4==0){
flag=1;//1이면 윤년
if(yr%100==0){
flag=0;
if(yr%400==0){
flag=1;
}
}
}
return flag;
}
int isThirtyOne(int mth){
if(mth==1||mth==3||mth==5||mth==7||mth==8||mth==10||mth==12){
return 1;
}else{
return 0;
}
}