#C964. Date Format Conversion
Date Format Conversion
Date Format Conversion
You are given a series of dates, each in one of the following formats:
- \( YYYY/MM/DD \)
- \( MM-DD-YYYY \)
- \( DD.MM.YYYY \)
Your task is to read the dates from standard input until you encounter a line containing the word end
(case-sensitive). For each valid date, convert it into the standardized format \( YYYY-MM-DD \) and print it to standard output on a separate line. If a date is given in an unsupported or invalid format, skip it.
For example, if the input is:
2023/10/14 04-15-2021 30.09.2020 end
the output should be:
2023-10-14 2021-04-15 2020-09-30
inputFormat
The input consists of several lines. Each line (except the termination line) contains a date in one of the supported formats. The input is terminated by a line containing only end
.
outputFormat
For each valid input date, output a line containing the date formatted as YYYY-MM-DD
. Invalid or unsupported formats should not produce any output.
2023/10/14
04-15-2021
30.09.2020
end
2023-10-14
2021-04-15
2020-09-30
</p>