From c49b969659d8761442a560f8feda436bfb7b01e8 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 27 Mar 2025 17:24:15 +0100 Subject: Ajout des cours du 10 au 27 mars --- semestre 2/informatique/tme/semaine6/rec_str.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 semestre 2/informatique/tme/semaine6/rec_str.c (limited to 'semestre 2/informatique/tme/semaine6/rec_str.c') diff --git a/semestre 2/informatique/tme/semaine6/rec_str.c b/semestre 2/informatique/tme/semaine6/rec_str.c new file mode 100644 index 0000000..a920af3 --- /dev/null +++ b/semestre 2/informatique/tme/semaine6/rec_str.c @@ -0,0 +1,19 @@ +#include +int est_deb(char* s1, char* s2) { + if (*s1 == '\0' || *s2 =='\0') return 1; + if (*s1 != *s2) return 0; + return est_deb(s1+1, s2+1); +} + +int est_incluse(char *sub, char* s) { + if (*s == '\0') return 0; + return est_deb(sub, s) ? 1 : est_incluse(sub, s+1); +} + +int main() { + printf("%d\n", est_deb("alpha", "alphabet")); + printf("%d\n", est_deb("alpaga", "alphabet")); + printf("%d\n", est_incluse("alp", "alphabet")); + printf("%d\n", est_incluse("apl", "alphabet")); + return 0; +} -- cgit v1.2.3