U E D R , A S I H C RSS

만년달력/곽세환,조재화

*^^* 해할 ㅠㅠ ...

~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;
}
,
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:25
Processing time 0.0128 sec