#define COG1_TEETH 4
#define COG2_TEETH 25
#define COG3_TEETH 4
#define BASE 1584
int isleap(int year);
int main(void) {
int year;
//printf("Please enter a year\n");
year = 2000;
//if (scanf("%d", &year) == 1) {
printf("%d is %s\n", year,
isleap(year) ? "a leap year" : "not a leap year");
//} else
// fputs("Input error", stdout);
return 0;
}
int isleap(int year) {
unsigned a, b, c;
unsigned i;
if (year < BASE) return 0; /* Not Gregorian year */
a = 0;
b = COG2_TEETH - COG1_TEETH;
c = COG3_TEETH - 1;
i = year - BASE;
while (i--) {
if (++a == COG1_TEETH) {
a = 0;
if (++b == COG2_TEETH) {
b = 0;
if (++c == COG3_TEETH)
c = 0;
}
}
}
return !b ? !a && !c : a == 0;
}