Commit dae0441e authored by luc.lambert1's avatar luc.lambert1
Browse files

ca marche :D

parent 3bdf000f
CC=gcc -Wextra -Wall -g -fsanitize=address -fsanitize=leak -pedantic
ex1.out: ex1.o
$(CC) $^ -o $@
ex1.o: ex1.c
$(CC) $< -c
clean:
@rm -f *.o *.out
rebuild: clean ex1.out
\ No newline at end of file
#include <stdio.h>
#include <stdlib.h>
double moyenne_recur(double* tab, int size, double moyenne,int index){
if(index == size){
return moyenne/size;
}
moyenne += tab[index];
moyenne_recur(tab, size, moyenne, ++index);
}
double* inverse_recu(double* tab, int size, int index){
if(index == size/2){
return tab;
}
double tmp = tab[(size-index)-1];
tab[(size-index)-1] = tab[index];
tab[index] = tmp;
tab = inverse_recu(tab, size, ++index);
}
int main() {
int size = 15;
double tab[size];
for(int i = 0; i < size ;i++){
scanf("%lf", &(tab[i]));
}
double moyenne = moyenne_recur(tab, size, 0, 0);
double* invtab = tab;
invtab = inverse_recu(invtab,size,0);
printf("moyenne: %lf\n", moyenne);
printf("inversion:\n");
for(int i = 0; i < size; i++){
printf("%lf\n", invtab[i]);
}
return EXIT_SUCCESS;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment