#include <iostream> #define isleap(x) ((x%4==0&&x%100!=0)||x%400==0)?1:0 using namespace std; int dayOfMonth[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(){ int y,m,d,sum=0; scanf("%d%d%d",&y,&m,&d); for(int j=1;j<m;j++){ sum+=dayOfMonth[j][isleap(y)]; } printf("%d",sum+d); return 0; } |
Double click to view unformatted code.