summaryrefslogtreecommitdiff
path: root/sem_2/HLIN202/TP/TP5-6
diff options
context:
space:
mode:
authorGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
committerGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
commit9fe033ea88c2f705ec18c232873d056e0c229d72 (patch)
tree0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_2/HLIN202/TP/TP5-6
Initial commit
Diffstat (limited to 'sem_2/HLIN202/TP/TP5-6')
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex11/exo11bin0 -> 13514 bytes
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex11/exo11.cpp29
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex12/exo12bin0 -> 9386 bytes
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex12/exo12.cpp23
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex13/ex13.cpp20
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex13/exo13bin0 -> 13499 bytes
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex5/exo5bin0 -> 9237 bytes
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex5/exo5.cpp14
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex6/exo6bin0 -> 9288 bytes
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex6/exo6.cpp20
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex7/exo7bin0 -> 13775 bytes
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex7/exo7.cpp14
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex7/exo7intbin0 -> 9195 bytes
-rw-r--r--sem_2/HLIN202/TP/TP5-6/ex7/exo7int.cpp14
14 files changed, 134 insertions, 0 deletions
diff --git a/sem_2/HLIN202/TP/TP5-6/ex11/exo11 b/sem_2/HLIN202/TP/TP5-6/ex11/exo11
new file mode 100644
index 0000000..181c922
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex11/exo11
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP5-6/ex11/exo11.cpp b/sem_2/HLIN202/TP/TP5-6/ex11/exo11.cpp
new file mode 100644
index 0000000..7b88eaa
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex11/exo11.cpp
@@ -0,0 +1,29 @@
+#include<iostream>
+#include<math.h>
+
+int solveurseconddeg ( double a, double b, double c, double * x1, double * x2) {
+ double delta = (b*b)-(4*a*c);
+ if (delta > 0) {
+ *x1 = (-b-sqrt(delta))/(2*a);
+ *x2 = (-b+sqrt(delta))/(2*a);
+ return 2;
+ }
+ else if ( delta == 0 && a!=0) {
+ *x1=-b/(2*a);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+int main () {
+ double a = 1, b=1, c=1;
+ double rslt1, rslt2;
+ std::cout<< " Entrez a, b et c, ce programme calcule les racines du polynome ax^2+bx+c : "<<std::endl;
+ std::cin >> a >> b >> c ;
+ int racines = solveurseconddeg(a,b,c,&rslt1,&rslt2);
+ if ( racines==0) { std::cout<<"Le polynome n'a pas de solution"<<std::endl;}
+ else if (racines == 1) { std::cout<<"Le polynome a une racine : " << rslt1 << std::endl;}
+ else if ( racines == 2) { std::cout << "Le polynome a deux racines : " << rslt1 << " et : " << rslt2<< std::endl;}
+ return 0;
+}
diff --git a/sem_2/HLIN202/TP/TP5-6/ex12/exo12 b/sem_2/HLIN202/TP/TP5-6/ex12/exo12
new file mode 100644
index 0000000..d286648
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex12/exo12
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP5-6/ex12/exo12.cpp b/sem_2/HLIN202/TP/TP5-6/ex12/exo12.cpp
new file mode 100644
index 0000000..903014c
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex12/exo12.cpp
@@ -0,0 +1,23 @@
+#include<iostream>
+
+void OnePgcdStep ( int *u, int *v) {
+ int w,x;
+ w= *v % *u;
+ x= *u % w;
+ *u= w;
+ *v= x;
+}
+
+int pgcd (int a, int b) {
+ while (b!=0) {
+ OnePgcdStep(&a,&b);
+ }
+ return a;
+}
+
+int main () {
+ int a,b;
+ std::cin>> a >> b;
+ std::cout<<"Le PGCD de ("<<a<<","<<b << ") est : "<<pgcd(a,b)<<std::endl;
+ return 0;
+}
diff --git a/sem_2/HLIN202/TP/TP5-6/ex13/ex13.cpp b/sem_2/HLIN202/TP/TP5-6/ex13/ex13.cpp
new file mode 100644
index 0000000..d61c5b0
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex13/ex13.cpp
@@ -0,0 +1,20 @@
+#include<iostream>
+
+int main () {
+ int x;
+ float y;
+ int *ptr;
+ float *ptr2;
+ std::cout<<" Entrez un nombre entier" << std::endl;
+ std::cin>>x;
+ ptr=&x;
+ ptr2 = (float*)ptr;
+
+ std::cout<<"L'entier "<< x << " vaut " << *ptr2 << " en interpretation flottante" << std::endl;
+ std::cout<<" Entrez un nombre flottant" << std::endl;
+ std::cin>>y;
+ ptr2 = &y;
+ ptr = (int*)ptr2;
+ std::cout<<"Le flottant "<< y << " vaut " << *ptr << " en interpretation entiere" << std::endl;
+ return 0;
+}
diff --git a/sem_2/HLIN202/TP/TP5-6/ex13/exo13 b/sem_2/HLIN202/TP/TP5-6/ex13/exo13
new file mode 100644
index 0000000..be66305
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex13/exo13
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP5-6/ex5/exo5 b/sem_2/HLIN202/TP/TP5-6/ex5/exo5
new file mode 100644
index 0000000..739ade0
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex5/exo5
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP5-6/ex5/exo5.cpp b/sem_2/HLIN202/TP/TP5-6/ex5/exo5.cpp
new file mode 100644
index 0000000..ae369d4
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex5/exo5.cpp
@@ -0,0 +1,14 @@
+#include <iostream>
+
+int* max ( int* a, int* b, int* c) {
+ if ( *a>=*b && *a>=*c) return a;
+ if ( *b>=*a && *b>=*c) return b;
+ if ( *c>=*a && *c>=*b) return c;
+ else return 0;
+}
+
+int main () {
+ int x=2, y=4, z=3;
+ std::cout<<"le max est à l'adresse : " << max(&x,&y,&z) << std::endl;
+ return 0;
+}
diff --git a/sem_2/HLIN202/TP/TP5-6/ex6/exo6 b/sem_2/HLIN202/TP/TP5-6/ex6/exo6
new file mode 100644
index 0000000..991cc87
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex6/exo6
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP5-6/ex6/exo6.cpp b/sem_2/HLIN202/TP/TP5-6/ex6/exo6.cpp
new file mode 100644
index 0000000..059404d
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex6/exo6.cpp
@@ -0,0 +1,20 @@
+#include<iostream>
+
+void addima (double x, double y, double x2, double y2, double * xrslt, double * yrslt ) {
+ *xrslt = x + x2;
+ *yrslt = y + y2;
+}
+
+void multima (double x, double y, double x2, double y2, double * xrslt, double * yrslt ) {
+ *xrslt = x*x2 + x*y2;
+ *yrslt = y*x2 + y*y2;
+}
+
+int main () {
+ double x=2,y=3,x2=5,y2=1, rsltx, rslty;
+ addima(x,y,x2,y2,&rsltx,&rslty);
+ std::cout<<"(2+3i) +(5+i) = "<< rsltx <<" + " << rslty << "i"<<std::endl;
+ multima(x,y,x2,y2,&rsltx,&rslty);
+ std::cout<<"(2+3i)*(5+i) = "<< rsltx <<" + " << rslty << "i"<<std::endl;
+ return 0;
+}
diff --git a/sem_2/HLIN202/TP/TP5-6/ex7/exo7 b/sem_2/HLIN202/TP/TP5-6/ex7/exo7
new file mode 100644
index 0000000..238c136
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex7/exo7
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP5-6/ex7/exo7.cpp b/sem_2/HLIN202/TP/TP5-6/ex7/exo7.cpp
new file mode 100644
index 0000000..f37648c
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex7/exo7.cpp
@@ -0,0 +1,14 @@
+#include<iostream>
+
+int main () {
+ double a;
+ double c;
+ double b;
+ double *adda=&a;
+ double *addb=&b;
+ double *addc=&c;
+ double shift = (addb-adda) *(sizeof(double));
+ std::cout<< adda << " et " << addb << " et " << shift << std::endl;
+ std::cout<<"La distance en memoire ( en octets ) entre les deux variables a et b est : "<< std::hex << shift <<std::endl;
+ return 0;
+}
diff --git a/sem_2/HLIN202/TP/TP5-6/ex7/exo7int b/sem_2/HLIN202/TP/TP5-6/ex7/exo7int
new file mode 100644
index 0000000..640f5cd
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex7/exo7int
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP5-6/ex7/exo7int.cpp b/sem_2/HLIN202/TP/TP5-6/ex7/exo7int.cpp
new file mode 100644
index 0000000..e5b6b83
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP5-6/ex7/exo7int.cpp
@@ -0,0 +1,14 @@
+#include<iostream>
+
+int main () {
+ int a;
+ int table;
+ int chaise;
+ int b;
+ int *adda=&a;
+ int *addb=&b;
+ long *shift = (long*)(addb - adda);
+ std::cout<< adda << " et " << addb << " et " << (int)shift*sizeof(int) << std::endl;
+ std::cout<<"La distance en memoire ( en octets ) entre les deux variables a et b est : " << shift <<std::endl;
+ return 0;
+}