The first few days Hdu Oj

The first few days

A very simple, but they pay six times before AC.

第几天?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 249962 Accepted Submission(s): 86243

Problem Description
Given a date, output of this date is the first day of the year.

Input
input data multiple groups, each accounting for one line, the data in the format YYYY / MM / DD composition details, see sample input, in addition, can you make sure that all of the input data is legitimate.

Output
For each case, an output line, indicating that the date is the first day of the year.

Sample Input
1985/1/20
2006/3/12

Sample Output
20
71

Author
lcy

It should be noted that no judgment leap year and the past month do not add a whole number of days, plus day directly on the line.

#include<stdio.h>
int main()
{
    int year,m,d;
    int x;
    int i,j,k;      //31,28,31,30,31,30,31,31,30,31,30,31
    int day[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31};//先定义出来会比较简单,就不用在后面判断哪个月有多少天了
    while(~scanf("%d/%d/%d",&year,&m,&d))
    {
        x=0;
       // if(m<1||m>12)
        //首先判断是否是闰年
        if((year%4==0&&year%100!=0)||(year%400==0))//判断是不是闰年,闰年二月29天。
        {
            day[2]=29;
        }
        else
            day[2]=28;
        for(i=0; i<m; i++)
        {
            x+=day[i];
        }
        x+=d;

        printf("%d\n",x);


    }


}
Published 18 original articles · won praise 0 · Views 268

Guess you like

Origin blog.csdn.net/qq_42815711/article/details/103840324