usage: hw2.cpp provide users to print the calendar, users can input a month, then print the previous, current, and next month. compile: g++ hw2.cpp
pseudocode int main(){ Let users input year; If year >= 1600, then let users input month { Print the previous, current, and next month; If users input January, then print the previous years December; If users input December, then print the next years January; } else Print error message; }
int FirstDayOfMonth(int year, int month){ Calculate what day is the first day of month; }
int SetDays(int year, int month){ If month is 1, 3, 5, 7, 8, 10, 12, then set days is 31; else if month is 4, 6, 9, 11, then set days is 30; else if month is 2 and is leap year, then set days is 29; else set days is 28; }
void Display(int year, int month){ Judge the month, and print its English. (ex: 1 = January, 2 = February, . Etc.) Print the space before the first day of the month, then print the first day; If the day is Saturday, then set the newline; for(the second day to the end of month){ Calculate what day is it; Print three space before each day; If the day is Saturday, then set the newline; } }
104 H34019011 Test Case
coded by Ting-Hui Fang(), ID: H34019011, email: H34019011@mail.ncku.edu.tw date: 2013.3.13