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_2.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 semestre 2/informatique/tme/semaine6/rec_2.c (limited to 'semestre 2/informatique/tme/semaine6/rec_2.c') diff --git a/semestre 2/informatique/tme/semaine6/rec_2.c b/semestre 2/informatique/tme/semaine6/rec_2.c new file mode 100644 index 0000000..9bfd376 --- /dev/null +++ b/semestre 2/informatique/tme/semaine6/rec_2.c @@ -0,0 +1,16 @@ +#include +int recherche_rec_aux (int* tab, int n,int i, int v) { + if (i == n) return -1; + if (tab[i] == v) return i; + return recherche_rec_aux(tab, n, i+1, v); +} + +int recherche_rec (int tab[], int taille, int elem) { + return recherche_rec_aux (tab, taille, 0, elem); +} + +int main() { + int arr[] = {1, 2, 3}; + printf("%d\n", recherche_rec(arr, 3, 0)); + return 0; +} -- cgit v1.2.3