#include <iostream> #include <cmath> #include <cstring> #include <algorithm> #define ISYEAR(x) (x%400==0||(x%4==0&&x%100!=0))?1:0 using namespace std; struct date{ int year,month,day; }; int md[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30, 31,31, 31,31, 30,30, 31,31, 30,30, 31,31 }; int main(){ date dat; cin>>dat.year>>dat.month>>dat.day; int s=0; for(int i=0;i<dat.month;i++){ s+=md[i][ISYEAR(dat.year)]; } s+=dat.day; cout<<s<<endl; return 0; } |
Double click to view unformatted code.