This commit is contained in:
2021-08-12 09:34:38 +02:00
parent 9542b0bf09
commit 69ffe15ed6
5 changed files with 194 additions and 0 deletions

24
c/leap/src/leap.c Normal file
View File

@@ -0,0 +1,24 @@
#include "leap.h"
/* already dont in meetup exercise */
bool leap_year(int y)
{
return ((y % 4) ||
(y % 400 && !(y % 100)))? false: true;
}
/* See GNUmakefile below for explanation
* https://github.com/braoult/exercism/blob/master/c/templates/GNUmakefile
*/
#ifdef UNIT_TEST
int main(int ac, char **av)
{
int arg=1, i;
for (; arg<ac; ++arg) {
i=atoi(av[arg]);
printf("leap_year(%d)=%d\n", i, leap_year(i));
}
}
#endif

20
c/leap/src/leap.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef LEAP_H
#define LEAP_H
#include <stdbool.h>
bool leap_year(int year);
/* See GNUmakefile below for explanation
* https://github.com/braoult/exercism/blob/master/c/templates/GNUmakefile
*/
#if defined UNIT_TEST || defined DEBUG
#include <stdio.h>
#include <stdlib.h>
#endif
#ifdef TESTALL
#undef TEST_IGNORE
#define TEST_IGNORE() {}
#endif
#endif