만 ¶
~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; },