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.c | |
| parent | 4a3afaf44aa29e66a6c879c60322015a2920a5ab (diff) | |
Ajout des cours du 10 au 27 mars
Diffstat (limited to 'semestre 2/informatique/tme/semaine6/rec.c')
| -rw-r--r-- | semestre 2/informatique/tme/semaine6/rec.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/semestre 2/informatique/tme/semaine6/rec.c b/semestre 2/informatique/tme/semaine6/rec.c new file mode 100644 index 0000000..0a5bb34 --- /dev/null +++ b/semestre 2/informatique/tme/semaine6/rec.c @@ -0,0 +1,12 @@ +#include <stdio.h> +int recherche_rec(int* arr, int n, int v){ + if (n == 0) return -1; + if (arr[n-1] == v) return n-1; + return recherche_rec(arr, n-1, v); +} + +int main() { + int arr[] = {1, 2, 3, 5, 5}; + printf("%d\n",recherche_rec(arr, 5, 6)); + return 0; +} |
