Created
April 29, 2019 08:08
-
-
Save FredrikAugust/3eda3d5464d8f6573c388cbc7a7b32a0 to your computer and use it in GitHub Desktop.
/r/dailyprogrammer #376
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> | |
int leaps(int from, int to) | |
{ | |
int count(0); | |
for (; from < to; from++) { | |
if ((from % 100 != 0 || (from % 900 == 200 || from % 900 == 600)) && from % 4 == 0) | |
count++; | |
} | |
printf("%d -> %d => %d\n", from, to, count); | |
return count; | |
} | |
int main(int argc, char const *argv[]) | |
{ | |
leaps(2016, 2017); | |
leaps(2019, 2020); | |
leaps(1900, 1901); | |
leaps(2000, 2001); | |
leaps(2800, 2801); | |
leaps(123456, 123456); | |
leaps(1234, 5678); | |
leaps(123456, 7891011); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment