-
-
Save kennethho/5829294 to your computer and use it in GitHub Desktop.
This file contains hidden or 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