Write a program that prints a one-month calendar. The user specifies 2 numbers in the input:
- The number of days in the month
- The day of the week on which the month begins ( starting day of the week: 1=Sun;2=Mon;3=Tue;4=Wed;5=Thu;6=Fri;7=Sat)
寫一個程式 印出指定月份的月曆:
- 輸入一整數代表這個月有幾天
- 輸入一整數代表這個月一號星期幾 (1=星期天,2=星期一,...)
Example input:
31
3
Example output:
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
Hint: The most important part is a for statement that uses a variable i to count from 1 to n, where n is the number of days in a month, printing each value of i. Inside the loop, an if statement tests whether i is the last day in a week; if so, it prints a newline.