#P9177. Magdalena's Calendar
Magdalena's Calendar
Magdalena's Calendar
Magdalena loves calendars and creates her own for each month. In her calendar, every day is represented by exactly three characters:
- If the day is a single digit, it is represented as
..X
(for example, the number \(7\) is represented as..7
). - If the day is two digits, it is represented as
.XY
(for example, the number \(17\) is represented as.17
).
The calendar is arranged by weeks (each row represents a week with 7 days). If the week does not have all 7 days (because the month might not start on Monday or end on Sunday), the missing days are represented by ...
.
Magdalena also wants her calendar to look nice. She decorates it by adding a top and bottom border filled with '-' (ASCII 45), left and right borders filled with '|' (ASCII 124), and the four corners are replaced with '+' (ASCII 43).
Your task is: given \(n\) (the number of days in the month) and \(x\) (the weekday index of the first day of the month, where \(x=1\) means Monday, \(x=2\) means Tuesday, and so on), print the decorated calendar as described. We assume that the week starts with Monday.
Formatting Details:
- Each day is printed as a 3-character string.
- Each week (row) consists of 7 such strings concatenated.
- If certain cells in a week do not correspond to a day in the month, print
...
for that cell. - The final calendar must be enclosed in a rectangular frame. The top and bottom borders consist of a '+' at each end with '-' filling the middle (the number of '-' equals exactly 21, which is \(7 \times 3\)). The left and right borders for each row are '|' characters.
inputFormat
The input consists of two integers \(n\) and \(x\), where:
- \(n\) is the number of days in the month. (1 \(\leq n \leq\) 100)
- \(x\) (1 \(\leq x \leq 7\)) indicates that the first day of the month is the \(x\)th day of the week (Monday is 1, Tuesday is 2, etc.).
The input is given on one line with a space separating \(n\) and \(x\).
outputFormat
Print the complete decorated calendar. The calendar must have a top and bottom border and each week row must be framed with '|' characters at the beginning and the end. The inner part of the calendar consists of rows, each of which is exactly 21 characters long (7 cells \(\times\) 3 characters). For days with a one-digit number, use the format ..X
, and for two-digit numbers, use .XY
. Cells not corresponding to a day should be printed as ...
.
sample
31 1
+---------------------+
|..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...........|
+---------------------+
</p>