Eighth session Blue Bridge Cup seventh question date

Source: Internet
Author: User
Tags min ming strcmp
Title: Date Issue
Xiao Ming is tidying up a batch of historical documents. Many dates appear in these historical documents. Xiaoming knows that these dates are from January 1, 1960 to December 31, 2059. To Xiao Ming's headache is that these dates adopted by the format is very non-uniform, with the use of the year/month/day, with the use of the month/day/year,
There are also days/months/years of use. More troubling is that the year also omitted the top two, so that a date in the literature, there are many possible dates and their corresponding.
such as 02/03/04, may be March 04, 2002, February 03, 2004 or March 02, 2004.
Given a date in the literature, can you help xiaoming to determine what possible dates correspond to them?
Input
----
A date in which the format is "AA/BB/CC". (0 <= A, B, C <= 9)
Output
----
Outputs several different dates, one row per date, and the format is "YYYY-MM-DD". Multiple dates are sorted from morning to night.
Sample input
----
02/03/04
Sample output
----
2002-03-04
2004-02-03
2004-03-02
Resource contract:
Peak memory consumption (with virtual machines) < 256M
CPU Consumption < 1000ms

Please strictly according to the requirements of the output, do not use the superfluous printing similar: "Please enter ..." Redundant content.

#include <stdio.h> #include <string.h> int main () {int x, y,i,g,h;
	Char date[20];
	Char a[20][20],min[20]= "19600101", max[20]= "20591231"; while (scanf ("%s", &date)!=eof) {a[0][0]= ' 1 '; a[0][1]= ' 9 '; a[0][2]=date[0];a[0][3]=date[1];a[0][4]=date[3];a[0]
		[5]=date[4];a[0][6]=date[6];a[0][7]=date[7];a[0][8]= ']; a[1][0]= ' 1 '; a[1][1]= ' 9 '; a[1][2]=date[6];a[1][3]=date[7];a[1][4]=date[0];a[1][5]=date[1];a[1][6]=date[3];a[1][7
		]=date[4];a[1][8]= ' + '; a[2][0]= ' 1 '; a[2][1]= ' 9 '; a[2][2]=date[6];a[2][3]=date[7];a[2][4]=date[3];a[2][5]=date[4];a[2][6]=date[0];a[2][7


		]=date[1];a[2][8]= ' + '; a[3][0]= ' 2 '; a[3][1]= ' 0 '; a[3][2]=date[0];a[3][3]=date[1];a[3][4]=date[3];a[3][5]=date[4];a[3][6]=date[6];a[3][7
		]=date[7];a[3][8]= ' + '; a[4][0]= ' 2 '; a[4][1]= ' 0 '; a[4][2]=date[6];a[4][3]=date[7];a[4][4]=date[0];a[4][5]=date[1];a[4][6]=date[3];a[4][7
		]=date[4];a[4][8]= ' + '; a[5][0]= ' 2 '; a[5][1]= ' 0 '; a[5][2]=date[6];a[5][3]=date[7];a[5][4]=date[3];a[5][5]=date[4];a[5][6]=date[0];a[5][7 ]=date[1];a[5][8]=' N ';
			for (i=0;i<6;i++) {x=strcmp (a[i],min);
			Y=STRCMP (A[i],max);
			g= (a[i][4]-' 0 ') *10+a[i][5]-' 0 ';
			h= (a[i][6]-' 0 ') *10+a[i][7]-' 0 '; if (g<1| | g>12 | | h<1| |
			H&GT;31) continue; if (x>=0 && y<=0) printf ("%c%c%c%c-%c%c-%c%c\n", A[i][0],a[i][1],a[i][2],a[i][3],a[i][4],a[i][5],a[i]
		[6],a[i][7]);
}} return 0;
 }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.