今年的第几天
今年的第几天?
https://www.nowcoder.com/practice/ae7e58fe24b14d1386e13e7d70eaf04d?tpId=40&&tqId=21350&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking
#include <iostream>
#include <cstdio>
using namespace std;
int dayTab[2][13]={
{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}
};
bool IsLeapYear(int year){
return (year%4==0&&year%100!=0 )||(year%400==0);
}
int main(){
int year,month,day;
while(scanf("%d%d%d",&year,&month,&day)!=EOF){
int number=0;
int row=IsLeapYear(year);
for(int j=0;j<month;j++)
number+=dayTab[row][j];
number+=day;
printf("%d\n",number);
}
return 0;
}