diff options
Diffstat (limited to 'euler19.c')
-rw-r--r-- | euler19.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/euler19.c b/euler19.c new file mode 100644 index 0000000..78a9d55 --- /dev/null +++ b/euler19.c @@ -0,0 +1,31 @@ +#include <stdio.h> + +const int days[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}}; + +int isleap(int y) +{ + if (y%4==0 && (y%100!=0 || y%400==0)) + return 1; + else + return 0; +} + +int main() +{ + int y,m,t; + int d=1+365,count=0; + for (y=1901;y<=2000;++y){ + t=isleap(y); + for (m=0;m<12;++m){ + d%=7; + if (d==0) + ++count; + d+=days[t][m]; + } + } + printf("%d\n",count); + return 0; +} + |