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

34
c/isogram/src/isogram.c Normal file
View File

@@ -0,0 +1,34 @@
#include "isogram.h"
#include <ctype.h>
#define POS(c) (tolower(c)-'a')
/* This does not work outside English world */
bool is_isogram(const char phrase[])
{
//int map['z'-'a'+1]={0};
int map[1000]={0};
const char *p=phrase;
if (!p)
return false;
for (; *p; ++p) {
if (*p==' ' || *p=='-')
continue;
if (!isalpha((unsigned char)*p) || (++map[POS((unsigned char)*p)])>1)
return false;
}
return true;
}
#ifdef UNIT_TEST
#include <stdio.h>
int main(int ac, char **av)
{
int arg=1;
for (; arg<ac; ++arg) {
printf("isogram[%s]=%d\n", av[arg], is_isogram(av[arg]));
}
}
#endif