Last active
December 18, 2015 18:50
-
-
Save moskytw/5828968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define NUM_OF_ELEMENTS(array) (sizeof(array)/sizeof(array[0])) | |
main() { | |
int ys[] = {2011, 2012, 2100, 2400}; | |
int i = 0, m = 0; | |
for(i = 0; i < NUM_OF_ELEMENTS(ys); i++) { | |
int y = ys[i]; | |
printf("year: %d\n", y); | |
for(m = 1; m <= 12; m++) { | |
int m_days = 30 + (m+(m>=8))%2 - 2*(m==2) + (m==2 && (!(y%4) && !!(y%100) || !(y%400))); | |
printf("%d\n", m_days); | |
} | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment