This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s4-c/TP3/E4.c

27 lines
501 B
C
Raw Normal View History

2016-03-09 08:36:37 +01:00
/* Recherche d'éléments sur critère */
#include <stdio.h>
int recherche(int n, double T[n]) {
int i;
for (i = 0; i < n; i++) {
if (T[i] < 0) {
return i;
}
}
return -1;
}
int main() {
int n, i;
printf("Nombre de nombres ? ");
scanf("%d", &n);
double T[n];
for (i = 0; i < n; i++) {
printf("Saisir le nombre %d : ", i+1);
scanf("%lf", &T[i]);
}
printf("Recherche : %lf\n", recherche(n, T)+1);
return 0;
}