TP3 E4
This commit is contained in:
parent
5023793832
commit
b225c20b2b
1
TP3/E3.c
1
TP3/E3.c
|
@ -33,4 +33,5 @@ int main() {
|
|||
}
|
||||
printf("Moyenne : %lf\n", moyenne(n, T));
|
||||
printf("Maximum : %lf\n", maximum(n, T));
|
||||
return 0;
|
||||
}
|
||||
|
|
26
TP3/E4.c
Normal file
26
TP3/E4.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* 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;
|
||||
}
|
Reference in a new issue