¶
했 *^^* 해할 형 함 ㅠㅠ 하...
~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; }환,화