#include <iostream> #include <algorithm> #include <vector> using namespace std; int f(int m,int flag){ if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){ return 31; } else if(m==2&&flag==1){ return 29; } else if(m==2){ return 28; } else{ return 30; } } int main(){ int y,m,d; cin>>y>>m>>d; int flag=0; if(y%400==0||(y%100!=0&&y%4==0)){ flag=1; } int temp=0; for(int i=1;i<=m-1;i++){ for(int j=1;j<=f(i,flag);j++){ temp++; } } cout<<temp+d; } |
Double click to view unformatted code.