aboutsummaryrefslogtreecommitdiff
path: root/semestre 2/informatique/tme/semaine6/rec.c
blob: 0a5bb34865db320d8b21fdd4839036b4b3644846 (plain)
1
2
3
4
5
6
7
8
9
10
11
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;
}