summaryrefslogtreecommitdiff
path: root/euler19.c
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-05-24 21:39:58 +0800
committerIru Cai <mytbk920423@gmail.com>2018-05-24 21:39:58 +0800
commit1eefd58ca4fdb5d2f51f657bfd70c9a89a4707db (patch)
treeabde0e4da3c7fe138f3874a94d8eb7d0e44c3224 /euler19.c
downloadproject_euler-1eefd58ca4fdb5d2f51f657bfd70c9a89a4707db.tar.xz
initial commit
Diffstat (limited to 'euler19.c')
-rw-r--r--euler19.c31
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;
+}
+