The Year 2000 Problem
input file: y2k.in output file: y2k.out
Older computer programs stored years in just two digits to save memory. This approach caused no trouble as long as the first two digits of every year were '19.' But, as we approach the year 2000, the first two digits are changing and so programs have to change. This is the Year 2000 (Y2K) Problem.
Write a program to go through documents and change all occurrences of two-digit years to four-digit years.
A big problem with solving the Y2K Problem is deciding when a numeric value represents a year. For the sake of this problem, a numeric value is considered to represent a year if it appears in a date. A date is a series of three one or two digit positive integers, separated by either hyphens or slashes, such as 12/2/98 or 19-4-96. (Note the separators must both be hyphens or both be slashes; a mix like 12-2/98 is not considered a date.) The third integer must have two digits for the three integers to be considered a date. So 3/4/05 is a date, but 6/7/8 is not.
The third integer of the three integers in a date represents the year. Your program should change this to a four digit year. If the given year is less than 10, it should be changed to 2000 plus the year. Otherwise, the year should be changed to 1900 plus the year. So, 12/2/98 should be changed to 12/2/1998 and 3-4-05 should be changed to 3-4-2005.
Input
A file containing text, with up to 80 characters on a line. Any "date" will not be preceded or followed by a hyphen or slash.
Output
A copy of the original file, with dates with two-digit years replaced with four-digit years. The file other than the two added digits for dates should be identical to the original.
Sample Input
Today is 10/24/98. Last year on this date it was
10-24-97. I hope over 3/4 of the teams will get this problem! It's not like asking 10-2, but it's not too hard.
I wonder where the contest will be on 10/24/00? How about on
99/99/99?
Sample Output (corresponding to the sample input)
Today is 10/24/1998. Last year on this date it was
10-24-1997. I hope over 3/4 of the teams will get this problem! It's not like asking 10-2, but it's not too hard.
I wonder where the contest will be on 10/24/2000? How about on 99/99/1999?