From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/piscine/check_alphabet/check_alphabet.c | 25 +++++++++++++++++++++++++ graphs/piscine/check_alphabet/check_alphabet.h | 6 ++++++ 2 files changed, 31 insertions(+) create mode 100644 graphs/piscine/check_alphabet/check_alphabet.c create mode 100644 graphs/piscine/check_alphabet/check_alphabet.h (limited to 'graphs/piscine/check_alphabet') diff --git a/graphs/piscine/check_alphabet/check_alphabet.c b/graphs/piscine/check_alphabet/check_alphabet.c new file mode 100644 index 0000000..fc540b4 --- /dev/null +++ b/graphs/piscine/check_alphabet/check_alphabet.c @@ -0,0 +1,25 @@ +#include "check_alphabet.h" + +#include + +int check_alphabet(const char *str, const char *alphabet) +{ + if (alphabet == NULL || *alphabet == '\0') + { + return 1; + } + + for (int i = 0; alphabet[i]; i++) + { + int j; + for (j = 0; str[j] && str[j] != alphabet[i]; j++) + { + continue; + } + if (str[j] == '\0') + { + return 0; + } + } + return 1; +} diff --git a/graphs/piscine/check_alphabet/check_alphabet.h b/graphs/piscine/check_alphabet/check_alphabet.h new file mode 100644 index 0000000..667a20f --- /dev/null +++ b/graphs/piscine/check_alphabet/check_alphabet.h @@ -0,0 +1,6 @@ +#ifndef CHECK_ALPHABET_H +#define CHECK_ALPHABET_H + +int check_alphabet(const char *str, const char *alphabet); + +#endif /* !CHECK_ALPHABET_H */ -- cgit v1.2.3