20 lines
355 B
C
20 lines
355 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int f(const int t[], uint len, int x) {
|
|
uint i = 0;
|
|
while (i < len) {
|
|
if (t[i] == x) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int main() {
|
|
int t[3] = {3, 6, 7};
|
|
printf("emplacement de 6 : %d\n", f(t, 3, 6));
|
|
printf("emplacement de 4 : %d\n", f(t, 3, 4));
|
|
}
|