Skip to content

Instantly share code, notes, and snippets.

@moskytw
Last active December 18, 2015 18:50
Show Gist options
  • Save moskytw/5828968 to your computer and use it in GitHub Desktop.
Save moskytw/5828968 to your computer and use it in GitHub Desktop.
#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