#include<iostream>#include<vector>usingnamespace std;//是否是闰年intisLeap(int year){if((year %4==0&& year %100!=0)|| year %400==0){return1;}else{return0;}}//闰年和平年各月天数int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31},};//字符串日期切分成 y年 m月 d日voidtrans(string str,int&y,int&m,int&d){
str +="/";
string temp;
vector<string> vec_temp;for(int i =0; str[i]!='\0';++i){if(str[i]=='/'){
vec_temp.push_back(temp);
temp ="";}else{
temp += str[i];}}
y =stoi(vec_temp[0]);
m =stoi(vec_temp[1]);
d =stoi(vec_temp[2]);}//判断给定日期是一年中的哪一天voidwhichDays(string str){int y, m, d;trans(str, y, m, d);int total_days = d;
y =isLeap(y);for(int i =0; i < m -1;++i){
total_days += month[y][i];}
cout << total_days << endl;}//骚操作入口intmain(){whichDays("2006/3/12");return0;}