F - The first few days? HDU - 2005
Given a date, output of this date is the first day of the year.
Input
Enter 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
Code Example:
#include<stdio.h>
#define N 12
int main(){
int year,month,day,sum;
while(~scanf("%d/%d/%d",&year,&month,&day)){
sum=0; //多组输入中有些数据一定要注意初始化。
int a[N]={31,28,31,30,31,30,31,31,30,31,30,31};
if(year%4==0&&year%100!=0||year%400==0)
a[1]=29;
for(int i=0;i<month-1;i++)
sum=sum+a[i];
sum=sum+day;
printf("%d\n",sum);
}
}
Of course, you can also use the case to write, but do not like feeling very lengthy.