update
This commit is contained in:
@@ -1,40 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int bilan(int tab[], int taille){
|
|
||||||
int i,n = taille, nb_suivant;
|
|
||||||
|
|
||||||
if(n==0){
|
|
||||||
printf("%d\n", taille);
|
|
||||||
return tab[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_suivant = bilan(tab + 1, taille - 1);
|
|
||||||
return (tab[0]>0) ? tab[0] : nb_suivant;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
|
||||||
int n;
|
|
||||||
int *tab;
|
|
||||||
|
|
||||||
n = argc - 1;
|
|
||||||
valeurs = (int*)malloc(n * sizeof(int));
|
|
||||||
if (valeurs == NULL) {
|
|
||||||
fprintf(stderr, "Erreur d'allocation mémoire\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
tab[i] = atoi(argv[i + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("%d\n", bilan(tab, taille));
|
|
||||||
|
|
||||||
free(tab);
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user