判断闰年 https://www.zhihu.com/question/25388501

#include<bits/stdc++.h>
using namespace std;

// 判断是否是闰年,闰年2月29天,平年2月28天
int is_leap_year(int year){
    if((year%4==0 && year%100!=0) || (year%400==0)){
        return 29;
    }else{
        return 28;
    }
}

// 定义月份
int days[] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(){
    string str;
    int year, month, day,count;
    while(getline(cin,str)){
        count = 0;
        int pos = str.find(' ', 0);
        year = stoi(str.substr(0, pos));

        int flag = pos + 1;
        pos = str.find(' ', flag);
        month = stoi(str.substr(flag, pos - flag));

        day = stoi(str.substr(pos+1));
        days[1] = is_leap_year(year);
        for (int i = 0; i < month-1;i++){
            count += days[i];
        }
        count += day;
        cout << count << endl;
    }

    return 0;
}