-->
当前位置:首页 > 题库

PROGRAMMING:Print a month calendar

Luz5年前 (2021-05-10)题库585
Programming: input any year and month, output the Gregorian calendar of the month (require cycle control printing).
Tips:
1. First, find out the total number of days from January 1, A.D. to the first day of this month, and find out the day of the week that the first day of this month is.
2. You can save the days of each month in an array, but you don't need to save every day of a month in an array.
common problem:
1. How to control the printing position of the first day of a month?
Answer: first calculate the day of the week on the first day of the month by the program, and then control to print the corresponding number of spaces before printing "1".
2. How to control weekly and monthly print line feed?
A: you can control the weekly print line feed according to the current printing position of the day, and control the monthly print line feed according to the total days of the month.
###Input format:
Enter the year and month, separated by spaces.
###Output format:
Each item is 4 characters wide, right aligned.
###Input example:
```in
2019 10
```
###Output example:
```out
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
```







answer:If there is no answer, please comment