¶
~cpp
#include<iostream>
using namespace std;
bool isYunYear(int x); //
int monthDays(int x,int y); // 계
int main()
{
int year, month; // year,month ,
cin >> year >> month; // year 고 , month 고 .
int yunYear4Year = year / 4;
int yunYear100Year = year / 100;
int yunYear400Year = year / 400;
int yunYearTotal = yunYear4Year - yunYear100Year + yunYear400Year;
int weekDay = (year + yunYearTotal) % 7; // (year+z)%7 1
for(int i = 0 ; i < month-1 ; i++)
{
weekDay=( weekDay+monthDays(year,i+1)%7 ) %7; // 구.
}
cout<<""<<"\t"<<""<<"\t"<<""<<"\t"<<""<<"\t"<<""<<"\t"<<"금"<<"\t"<<""<<endl;
for(i=0; i<weekDay; i++)
cout << " \t";
for(i=0 ; i<monthDays(year,month); i++)
{
cout << i+1 << "\t";//
weekDay = weekDay+1;
if(weekDay==7)//0~6 ~ 고 값 .
{
weekDay=0;
cout << endl;
}
}
cout<<endl;
return 0;
}
bool isYunYear(int x)// 계
{
if(x%4 ==0)
{
if(x%100 ==0)
{
if(x%400 ==0)
return true;
return false;
}
return true;
}
return false;
}
int monthDays(int x, int y)// 계
{
if( y==1 || y==3 || y==5 || y==7 || y==8 || y== 10 || y==12)
return 31;//1 3.... 31 까 .
else if( y==2)//2 29 28...
{
if(isYunYear(x)==true)
return 29;
return 28;
}
else//그 30
return 30;
}
. 기...
~cpp
#include<iostream>
using namespace std;
bool isYunYear(int x); //
int monthDays(int x,int y); // 계
int getMonthWeekDay(int x, int y);
int main()
{
int year, month; // year,month ,
cin >> year >> month; // year 고 , month 고 .
int yunYear4Year = year / 4;
int yunYear100Year = year / 100;
int yunYear400Year = year / 400;
int yunYearTotal = yunYear4Year - yunYear100Year + yunYear400Year;
int weekDay = (year + yunYearTotal) % 7; // (year+z)%7 1
for(int i = 0 ; i < month-1 ; i++)
{
getMonthWeekDay(weekDay,monthDays(year,i+1)%7); // 구.
}
cout<<""<<"\t"<<""<<"\t"<<""<<"\t"<<""<<"\t"<<""<<"\t"<<"금"<<"\t"<<""<<endl;
for(i=0; i<weekDay; i++)
cout << " \t";
for(i=0 ; i<monthDays(year,month); i++)
{
cout << i+1 << "\t";//
weekDay = weekDay+1;
if(weekDay==7)//0~6 ~ 고 값 .
{
weekDay=0;
cout << endl;
}
}
cout<<endl;
return 0;
}
bool isYunYear(int x)// 계
{
if(x%4 ==0)
{
if(x%100 ==0)
{
if(x%400 ==0)
return true;
return false;
}
return true;
}
return false;
}
int monthDays(int x, int y)// 계
{
if( y==1 || y==3 || y==5 || y==7 || y==8 || y== 10 || y==12)
return 31;//1 3.... 31 까 .
else if( y==2)//2 29 28...
{
if(isYunYear(x)==true)
return 29;
return 28;
}
else//그 30
return 30;
}
int getMonthWeekDay(int x, int y)
{
return x=(x+y) %7;
}
곽,









