summaryrefslogtreecommitdiff
path: root/sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp')
-rw-r--r--sem_4/Algo/TP2/SolutionsFonctionMysterieuses.cpp47
1 files changed, 47 insertions, 0 deletions
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 <iostream>
+#include <cmath>
+#include <stdlib.h> /* 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"<<numeroFonction<<"("<<i<<") renvoie "<<v<<" "<< f5(i)/pow(2,i)<<std::endl;
+}
+
+
+
+ return 0;
+}
+
+/*
+ordre de compilation : g++ SolutionsFonctionMysterieuses.cpp fonctionsMysterieuses.o -o test
+Ordre d'ex�cution : ./test 1 2
+*/
+
+/*f1(x)= 3 * sqrt(x)
+ f2(x)= 1/10* x^5
+ f3(x)= 1/2 * n^2
+ f4(x) = 2 * ln(x)
+ f5(x)= 10* 2^n
+ f6(x)=20 * 3^n
+*/