#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+day); return 0; } /* Main.cc: In function 'int main()': Main.cc:2:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses] #define isleap(x) x%4==0&&x%100!=0 || x%400==0 ?1:0 ^ Main.cc:25:24: note: in expansion of macro 'isleap' sum+=dayOfMonth[j][isleap(y)]; ^ Main.cc:27:19: error: 'day' was not declared in this scope printf("%d",sum+day); ^ */ |
Double click to view unformatted code.