initial commit

This commit is contained in:
2021-08-08 21:11:22 +02:00
commit fe7136d801
130 changed files with 6858 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include "resistor_color_duo.h"
#if defined UNIT_TEST || defined DEBUG
#include <stdio.h>
#include <stdlib.h>
#endif
resistor_band_t color_code(resistor_band_t *colors)
{
resistor_band_t c1=*colors, c2=*(colors+1);
return c1>=BLACK && c1<=WHITE && c2>=BLACK && c2<=WHITE? c1*10+c2: ERROR;
}
#ifdef UNIT_TEST
int main(int ac, char **av)
{
int arg=1;
resistor_band_t i[2];
for (; arg<ac-1; ++arg, ++arg) {
*i=atoi(av[arg]);
*(i+1)=atoi(av[arg+1]);
printf("color(%d, %d)=%d\n", i[0], i[1], color_code(i));
}
}
#endif

View File

@@ -0,0 +1,25 @@
#ifndef RESISTOR_COLOR_DUO_H
#define RESISTOR_COLOR_DUO_H
typedef enum {
BLACK=0,
BROWN,
RED,
ORANGE,
YELLOW,
GREEN,
BLUE,
VIOLET,
GREY,
WHITE,
ERROR=-1,
} resistor_band_t;
extern resistor_band_t color_code(resistor_band_t *);
#ifdef TESTALL
#undef TEST_IGNORE
#define TEST_IGNORE() {}
#endif
#endif