C: run-length-encoding

This commit is contained in:
2021-09-10 18:21:53 +02:00
parent 9a3d216a65
commit 67b2d3ec40
9 changed files with 544 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include "run_length_encoding.h"
/* 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, what;
char *res;
what = *av[arg++]; /* 'e', 'd' */
for (; arg<ac; ++arg) {
switch (what) {
case 'e':
printf("enc[%s]=%d [%s]\n", av[arg], encode_len(av[arg]),
res=encode(av[arg]));
printf("dec[%s]=%d [%s]\n", res, decode_len(res), decode(res));
break;
case 'd':
printf("dec[%s]=%d [%s]\n", av[arg], encode_len(av[arg]),
res=decode(av[arg]));
printf("enc[%s]=%d [%s]\n", res, decode_len(res), decode(res));
}
}
}
#endif