C: leap
This commit is contained in:
24
c/leap/src/leap.c
Normal file
24
c/leap/src/leap.c
Normal 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
20
c/leap/src/leap.h
Normal 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
|
Reference in New Issue
Block a user