diff options
| author | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-03-27 17:24:15 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-03-27 17:24:15 +0100 |
| commit | c49b969659d8761442a560f8feda436bfb7b01e8 (patch) | |
| tree | 70e34b6cc1b4285e009f9acace8c87a869d6ccb2 /semestre 2/informatique/tme/semaine6/rec_str.c | |
| parent | 4a3afaf44aa29e66a6c879c60322015a2920a5ab (diff) | |
Ajout des cours du 10 au 27 mars
Diffstat (limited to 'semestre 2/informatique/tme/semaine6/rec_str.c')
| -rw-r--r-- | semestre 2/informatique/tme/semaine6/rec_str.c | 19 |
1 files changed, 19 insertions, 0 deletions
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 <stdio.h> +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; +} |
