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_2/HLIN202/TP/TP5-6/ex11/exo11 | Bin 0 -> 13514 bytes sem_2/HLIN202/TP/TP5-6/ex11/exo11.cpp | 29 +++++++++++++++++++++++++++++ sem_2/HLIN202/TP/TP5-6/ex12/exo12 | Bin 0 -> 9386 bytes sem_2/HLIN202/TP/TP5-6/ex12/exo12.cpp | 23 +++++++++++++++++++++++ sem_2/HLIN202/TP/TP5-6/ex13/ex13.cpp | 20 ++++++++++++++++++++ sem_2/HLIN202/TP/TP5-6/ex13/exo13 | Bin 0 -> 13499 bytes sem_2/HLIN202/TP/TP5-6/ex5/exo5 | Bin 0 -> 9237 bytes sem_2/HLIN202/TP/TP5-6/ex5/exo5.cpp | 14 ++++++++++++++ sem_2/HLIN202/TP/TP5-6/ex6/exo6 | Bin 0 -> 9288 bytes sem_2/HLIN202/TP/TP5-6/ex6/exo6.cpp | 20 ++++++++++++++++++++ sem_2/HLIN202/TP/TP5-6/ex7/exo7 | Bin 0 -> 13775 bytes sem_2/HLIN202/TP/TP5-6/ex7/exo7.cpp | 14 ++++++++++++++ sem_2/HLIN202/TP/TP5-6/ex7/exo7int | Bin 0 -> 9195 bytes sem_2/HLIN202/TP/TP5-6/ex7/exo7int.cpp | 14 ++++++++++++++ 14 files changed, 134 insertions(+) create mode 100644 sem_2/HLIN202/TP/TP5-6/ex11/exo11 create mode 100644 sem_2/HLIN202/TP/TP5-6/ex11/exo11.cpp create mode 100644 sem_2/HLIN202/TP/TP5-6/ex12/exo12 create mode 100644 sem_2/HLIN202/TP/TP5-6/ex12/exo12.cpp create mode 100644 sem_2/HLIN202/TP/TP5-6/ex13/ex13.cpp create mode 100644 sem_2/HLIN202/TP/TP5-6/ex13/exo13 create mode 100644 sem_2/HLIN202/TP/TP5-6/ex5/exo5 create mode 100644 sem_2/HLIN202/TP/TP5-6/ex5/exo5.cpp create mode 100644 sem_2/HLIN202/TP/TP5-6/ex6/exo6 create mode 100644 sem_2/HLIN202/TP/TP5-6/ex6/exo6.cpp create mode 100644 sem_2/HLIN202/TP/TP5-6/ex7/exo7 create mode 100644 sem_2/HLIN202/TP/TP5-6/ex7/exo7.cpp create mode 100644 sem_2/HLIN202/TP/TP5-6/ex7/exo7int create mode 100644 sem_2/HLIN202/TP/TP5-6/ex7/exo7int.cpp (limited to 'sem_2/HLIN202/TP/TP5-6') 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 Binary files /dev/null and b/sem_2/HLIN202/TP/TP5-6/ex11/exo11 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 +#include + +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 : "<> a >> b >> c ; + int racines = solveurseconddeg(a,b,c,&rslt1,&rslt2); + if ( racines==0) { std::cout<<"Le polynome n'a pas de solution"< + +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 ("< + +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 Binary files /dev/null and b/sem_2/HLIN202/TP/TP5-6/ex13/exo13 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 Binary files /dev/null and b/sem_2/HLIN202/TP/TP5-6/ex5/exo5 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 + +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 Binary files /dev/null and b/sem_2/HLIN202/TP/TP5-6/ex6/exo6 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 + +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"< + +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 < + +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 <