C language birth date input and output

describe

Enter a person's date of birth (including year, month, and day), and output the year, month, and day of the birthday respectively.

Data range: the year satisfies 1990 \le y \le 2015 \1990≤y≤2015, the month satisfies 1 \le m \le 12 \1≤m≤12, and the day satisfies 1 \le d \le 30 \1≤d≤30 

Enter description:

Enter only one line, date of birth, including year, month and day, with no separators between the numbers.

Output description:

Three lines, the first line is the year of birth, the second line is the month of birth, and the third line is the date of birth. If the month or day number is 1 digit during output, 0 needs to be added in front of the 1 digit.

Example 1

enter:

20130225 

Output:

year=2013
month=02
date=25
#include<stdio.h>
int main()
{
    int year=0,month=0,date=0;
    scanf("%4d%2d%2d",&year,&month,&date);
    printf("year=%4d\n",year);
    printf("month=%02d\n",month);
    printf("date=%02d\n",date);
    return 0;
}

 

Guess you like

Origin blog.csdn.net/wangduduniubi/article/details/128538290