From 9fe033ea88c2f705ec18c232873d056e0c229d72 Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:05:53 +0200 Subject: Initial commit --- sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp (limited to 'sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp') diff --git a/sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp b/sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp new file mode 100644 index 0000000..4432f6a --- /dev/null +++ b/sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp @@ -0,0 +1,47 @@ +#include +#include +#include /* atoi */ + +#include "fonctionsMysterieuses.h" + +int apuissanceb(int a, int b) { +// renvoie a puissance b + if (b==0) return 1; + if (b % 2 == 0) return apuissanceb(a * a, b / 2); + return a * apuissanceb(a,b-1);} + +int main(int argv, char** argc){ + + int numeroFonction = atoi(argc[1]), + n = atoi(argc[2]), + v; + for (int i = 0; i < n; i+=1){ + + switch (numeroFonction) { + case 1 : v=f1(i); break; + case 2 : v=f2(i); break; + case 3 : v=f3(i); break; + case 4 : v=f4(i); break; + case 5 : v=f5(i); break; + case 6 : v=f6(i); break; + } + std::cout<<"f"<