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/TP1/autres/firstprog | Bin 0 -> 9140 bytes sem_2/HLIN202/TP/TP1/autres/firstprog.cpp | 7 ++ sem_2/HLIN202/TP/TP1/autres/secondprog | Bin 0 -> 9141 bytes sem_2/HLIN202/TP/TP1/autres/secondprog.cpp | 12 +++ sem_2/HLIN202/TP/TP1/ex56/exo56 | Bin 0 -> 9354 bytes sem_2/HLIN202/TP/TP1/ex56/exo56.cpp | 12 +++ sem_2/HLIN202/TP/TP1/ex7/exo7conv | Bin 0 -> 13448 bytes sem_2/HLIN202/TP/TP1/ex7/exo7conv.cpp | 22 +++++ sem_2/HLIN202/TP/TP1/nbparfait/parfait | Bin 0 -> 9295 bytes sem_2/HLIN202/TP/TP1/nbparfait/parfait.cpp | 21 +++++ sem_2/HLIN202/TP/TP11-12/exo 8.txt | 110 +++++++++++++++++++++++ sem_2/HLIN202/TP/TP11-12/exo10 | Bin 0 -> 13656 bytes sem_2/HLIN202/TP/TP11-12/exo10.cpp | 66 ++++++++++++++ sem_2/HLIN202/TP/TP11-12/exo11 | Bin 0 -> 13683 bytes sem_2/HLIN202/TP/TP11-12/exo11.cpp | 74 +++++++++++++++ sem_2/HLIN202/TP/TP11-12/exo5 | Bin 0 -> 13589 bytes sem_2/HLIN202/TP/TP11-12/exo5.cpp | 49 ++++++++++ sem_2/HLIN202/TP/TP11-12/exo6 | Bin 0 -> 14155 bytes sem_2/HLIN202/TP/TP11-12/exo6.cpp | 98 ++++++++++++++++++++ sem_2/HLIN202/TP/TP2/ex10/exo10-1 | Bin 0 -> 9293 bytes sem_2/HLIN202/TP/TP2/ex10/exo10-2 | Bin 0 -> 9350 bytes sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp | 17 ++++ sem_2/HLIN202/TP/TP2/ex11/exo11 | Bin 0 -> 9293 bytes sem_2/HLIN202/TP/TP2/ex11/exo11.cpp | 15 ++++ sem_2/HLIN202/TP/TP2/ex7/exo7 | Bin 0 -> 9294 bytes sem_2/HLIN202/TP/TP2/ex7/exo7.cpp | 27 ++++++ sem_2/HLIN202/TP/TP2/ex8/exo8 | Bin 0 -> 9297 bytes sem_2/HLIN202/TP/TP2/ex8/exo8.cpp | 13 +++ sem_2/HLIN202/TP/TP2/ex9/exo91 | Bin 0 -> 9293 bytes sem_2/HLIN202/TP/TP2/ex9/exo91.cpp | 14 +++ sem_2/HLIN202/TP/TP2/ex9/exo92 | Bin 0 -> 9293 bytes sem_2/HLIN202/TP/TP2/ex9/exo92.cpp | 14 +++ sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp | 33 +++++++ sem_2/HLIN202/TP/TP3-4/bonus/prog | Bin 0 -> 9263 bytes sem_2/HLIN202/TP/TP3-4/ex11/exo11 | Bin 0 -> 9336 bytes sem_2/HLIN202/TP/TP3-4/ex11/exo11.cpp | 21 +++++ sem_2/HLIN202/TP/TP3-4/ex12/exo12 | Bin 0 -> 9342 bytes sem_2/HLIN202/TP/TP3-4/ex12/exo12.cpp | 23 +++++ sem_2/HLIN202/TP/TP3-4/ex13/exo13 | Bin 0 -> 13775 bytes sem_2/HLIN202/TP/TP3-4/ex13/exo13.cpp | 137 ++++++++++++++++++++++++++++ sem_2/HLIN202/TP/TP3-4/ex6/exo6 | Bin 0 -> 13586 bytes sem_2/HLIN202/TP/TP3-4/ex6/exo6.cpp | 39 ++++++++ sem_2/HLIN202/TP/TP3-4/ex7/exo7 | Bin 0 -> 9285 bytes sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp | 34 +++++++ sem_2/HLIN202/TP/TP3-4/ex8/exo8 | Bin 0 -> 9388 bytes sem_2/HLIN202/TP/TP3-4/ex8/exo8.cpp | 25 ++++++ sem_2/HLIN202/TP/TP3-4/ex9/exo9 | Bin 0 -> 9276 bytes sem_2/HLIN202/TP/TP3-4/ex9/exo9.cpp | 29 ++++++ 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 +++ sem_2/HLIN202/TP/TP7-8/ex10/eo10 | Bin 0 -> 13586 bytes sem_2/HLIN202/TP/TP7-8/ex10/exo10.cpp | 118 ++++++++++++++++++++++++ sem_2/HLIN202/TP/TP7-8/ex6/exo6 | Bin 0 -> 9343 bytes sem_2/HLIN202/TP/TP7-8/ex6/exo6.cpp | 16 ++++ sem_2/HLIN202/TP/TP7-8/ex7/exo7 | Bin 0 -> 13482 bytes sem_2/HLIN202/TP/TP7-8/ex7/exo7.cpp | 22 +++++ sem_2/HLIN202/TP/TP7-8/ex8/exo8 | Bin 0 -> 13449 bytes sem_2/HLIN202/TP/TP7-8/ex8/exo8.cpp | 27 ++++++ sem_2/HLIN202/TP/TP7-8/ex9/exo9 | Bin 0 -> 9237 bytes sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp | 41 +++++++++ sem_2/HLIN202/TP/TP7-8/pendu/pendu | Bin 0 -> 13755 bytes sem_2/HLIN202/TP/TP7-8/pendu/pendu.cpp | 75 ++++++++++++++++ sem_2/HLIN202/TP/TP9-10/exo | Bin 0 -> 13743 bytes sem_2/HLIN202/TP/TP9-10/exo14/exo14 | Bin 0 -> 13443 bytes sem_2/HLIN202/TP/TP9-10/exo14/exo14.cpp | 40 +++++++++ sem_2/HLIN202/TP/TP9-10/exo6.cpp | 140 +++++++++++++++++++++++++++++ sem_2/HLIN202/TP/TP9-10/exopart2 | Bin 0 -> 13582 bytes sem_2/HLIN202/TP/TP9-10/exopart2.cpp | 51 +++++++++++ 80 files changed, 1576 insertions(+) create mode 100644 sem_2/HLIN202/TP/TP1/autres/firstprog create mode 100644 sem_2/HLIN202/TP/TP1/autres/firstprog.cpp create mode 100644 sem_2/HLIN202/TP/TP1/autres/secondprog create mode 100644 sem_2/HLIN202/TP/TP1/autres/secondprog.cpp create mode 100644 sem_2/HLIN202/TP/TP1/ex56/exo56 create mode 100644 sem_2/HLIN202/TP/TP1/ex56/exo56.cpp create mode 100644 sem_2/HLIN202/TP/TP1/ex7/exo7conv create mode 100644 sem_2/HLIN202/TP/TP1/ex7/exo7conv.cpp create mode 100644 sem_2/HLIN202/TP/TP1/nbparfait/parfait create mode 100644 sem_2/HLIN202/TP/TP1/nbparfait/parfait.cpp create mode 100644 sem_2/HLIN202/TP/TP11-12/exo 8.txt create mode 100644 sem_2/HLIN202/TP/TP11-12/exo10 create mode 100644 sem_2/HLIN202/TP/TP11-12/exo10.cpp create mode 100644 sem_2/HLIN202/TP/TP11-12/exo11 create mode 100644 sem_2/HLIN202/TP/TP11-12/exo11.cpp create mode 100644 sem_2/HLIN202/TP/TP11-12/exo5 create mode 100644 sem_2/HLIN202/TP/TP11-12/exo5.cpp create mode 100644 sem_2/HLIN202/TP/TP11-12/exo6 create mode 100644 sem_2/HLIN202/TP/TP11-12/exo6.cpp create mode 100644 sem_2/HLIN202/TP/TP2/ex10/exo10-1 create mode 100644 sem_2/HLIN202/TP/TP2/ex10/exo10-2 create mode 100644 sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp create mode 100644 sem_2/HLIN202/TP/TP2/ex11/exo11 create mode 100644 sem_2/HLIN202/TP/TP2/ex11/exo11.cpp create mode 100644 sem_2/HLIN202/TP/TP2/ex7/exo7 create mode 100644 sem_2/HLIN202/TP/TP2/ex7/exo7.cpp create mode 100644 sem_2/HLIN202/TP/TP2/ex8/exo8 create mode 100644 sem_2/HLIN202/TP/TP2/ex8/exo8.cpp create mode 100644 sem_2/HLIN202/TP/TP2/ex9/exo91 create mode 100644 sem_2/HLIN202/TP/TP2/ex9/exo91.cpp create mode 100644 sem_2/HLIN202/TP/TP2/ex9/exo92 create mode 100644 sem_2/HLIN202/TP/TP2/ex9/exo92.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/bonus/prog create mode 100644 sem_2/HLIN202/TP/TP3-4/ex11/exo11 create mode 100644 sem_2/HLIN202/TP/TP3-4/ex11/exo11.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/ex12/exo12 create mode 100644 sem_2/HLIN202/TP/TP3-4/ex12/exo12.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/ex13/exo13 create mode 100644 sem_2/HLIN202/TP/TP3-4/ex13/exo13.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/ex6/exo6 create mode 100644 sem_2/HLIN202/TP/TP3-4/ex6/exo6.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/ex7/exo7 create mode 100644 sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/ex8/exo8 create mode 100644 sem_2/HLIN202/TP/TP3-4/ex8/exo8.cpp create mode 100644 sem_2/HLIN202/TP/TP3-4/ex9/exo9 create mode 100644 sem_2/HLIN202/TP/TP3-4/ex9/exo9.cpp 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 create mode 100644 sem_2/HLIN202/TP/TP7-8/ex10/eo10 create mode 100644 sem_2/HLIN202/TP/TP7-8/ex10/exo10.cpp create mode 100644 sem_2/HLIN202/TP/TP7-8/ex6/exo6 create mode 100644 sem_2/HLIN202/TP/TP7-8/ex6/exo6.cpp create mode 100644 sem_2/HLIN202/TP/TP7-8/ex7/exo7 create mode 100644 sem_2/HLIN202/TP/TP7-8/ex7/exo7.cpp create mode 100644 sem_2/HLIN202/TP/TP7-8/ex8/exo8 create mode 100644 sem_2/HLIN202/TP/TP7-8/ex8/exo8.cpp create mode 100644 sem_2/HLIN202/TP/TP7-8/ex9/exo9 create mode 100644 sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp create mode 100644 sem_2/HLIN202/TP/TP7-8/pendu/pendu create mode 100644 sem_2/HLIN202/TP/TP7-8/pendu/pendu.cpp create mode 100644 sem_2/HLIN202/TP/TP9-10/exo create mode 100644 sem_2/HLIN202/TP/TP9-10/exo14/exo14 create mode 100644 sem_2/HLIN202/TP/TP9-10/exo14/exo14.cpp create mode 100644 sem_2/HLIN202/TP/TP9-10/exo6.cpp create mode 100644 sem_2/HLIN202/TP/TP9-10/exopart2 create mode 100644 sem_2/HLIN202/TP/TP9-10/exopart2.cpp (limited to 'sem_2/HLIN202/TP') diff --git a/sem_2/HLIN202/TP/TP1/autres/firstprog b/sem_2/HLIN202/TP/TP1/autres/firstprog new file mode 100644 index 0000000..4e0a5f5 Binary files /dev/null and b/sem_2/HLIN202/TP/TP1/autres/firstprog differ diff --git a/sem_2/HLIN202/TP/TP1/autres/firstprog.cpp b/sem_2/HLIN202/TP/TP1/autres/firstprog.cpp new file mode 100644 index 0000000..5440e7b --- /dev/null +++ b/sem_2/HLIN202/TP/TP1/autres/firstprog.cpp @@ -0,0 +1,7 @@ +#include + +int main(){ + std::cout<<"Félicitation, vous avez réussi à compiler et exécuter un programme C++"< + +int main(){ + + int a,b; + a=5; + b=8; + + std::cout<<"Félicitation, vous avez réussi à corriger un programme C++"< + +int main(){ + int a, b; + std::cout<< " Entrez a puis b" << std::endl; + std::cin>>a >> b; + std::cout<<"a*b = "<< a*b < + +int main(){ + float a,c; + int b=1; + std::cout<< " Entrez une temperature en fahrenheit ou en celcius" << std::endl; + std::cin>>a; + std::cout<<"Est ce en fahrenheit (1) ou en celcius(2)?"<> b; + if ( b == 1) { + c = ( a - 32 )* (5.0/9.0); + std::cout< +#include + +int main(){ + int n, som; + std::cout<<" Ce programme calcule les nombre parfaits inferieurs ou egaux a n, entrez n :"<> n; + std::cout << " Les nombres parfaits inferieur ou egaux a " << n << " sont : " <> ret.degree; + ret.coefs = new double[ret.degree]; + return ret; +} +2) void init ( polynome * poly ) { + for ( int i= 0; i < poly->degree; i ++ ) { + std::cout<<" Entrez le coefficient pour x^" << i <> poly->coefs[i]; + std::cout<cardinal ++; + cellule * ptr = new cellule; + ptr->contenu = n; + ptr->suivant = pil->premier; + pil->premier = ptr; +} + +5 ) int depiler (pile * pil) { + pil->cardinal --; +int ret = pil->premier->contenu; +cellule * ptr = pil->premier->suivant; +delete pil->premier; +pil->premier = ptr; +return ret; +} + +6 ) +void libere ( pile * pil) { +cellule*cell= pil->premier; +while ( cell->suivant != NULL) { + delete cell; + cell = cell->suivant; +} +delete[] cell; +delete[] pil; +} + +7 ) void affichepile ( pile pil ) { +cellule *cell = pil.premier; +std::cout<contenu<< " "; +while ( cell->suivant != NULL ) { +cell= cell->suivant; +std::cout<contenu << " "; +} +cell= cell->suivant; +std::cout<contenu << " "; +} + + + diff --git a/sem_2/HLIN202/TP/TP11-12/exo10 b/sem_2/HLIN202/TP/TP11-12/exo10 new file mode 100644 index 0000000..b22cbfc Binary files /dev/null and b/sem_2/HLIN202/TP/TP11-12/exo10 differ diff --git a/sem_2/HLIN202/TP/TP11-12/exo10.cpp b/sem_2/HLIN202/TP/TP11-12/exo10.cpp new file mode 100644 index 0000000..f53abed --- /dev/null +++ b/sem_2/HLIN202/TP/TP11-12/exo10.cpp @@ -0,0 +1,66 @@ +#include +#include +struct vecteur { + int dimension; + char nom; + double *coords; +}; + +vecteur* init ( int taille, char nom) { + vecteur * ret = new vecteur; + ret->dimension= taille; + ret->coords = new double[taille]; + ret->nom=nom; + for ( int i =0; i < taille; i ++) { + ret->coords[i]=0; + } + return ret; +} + +vecteur * oppose ( vecteur * vect) { + vecteur * ret = init(vect->dimension, vect->nom); + for ( int i =0; i < vect->dimension; i ++) { + ret->coords[i]= -vect->coords[i]; + } + return ret; +} + +vecteur * somme ( vecteur * vect1, vecteur * vect2) { + if ( vect1->dimension == vect2->dimension) { + char nom = 's'; + vecteur * ret=init ( vect1->dimension, nom); + for ( int i =0; i < ret->dimension; i ++) { + ret->coords[i]= vect1->coords[i]+ vect2->coords[i]; +} +return ret; +} +return 0; +} + +double scalaire ( vecteur * u, vecteur * v ) { + if ( u->dimension != v->dimension) { + std::cout<< " erreur " << std::endl; + return 0; } + double ret=0; + for ( int i = 0; i < u->dimension; i ++) { + ret += u->coords[i]*v->coords[i]; + } + return ret; +} + +double norme ( vecteur * u ) { + return sqrt(scalaire ( u,u)); +} + +int main () { + vecteur * u = init(2, *"u"); + vecteur * v = init(2, *"v"); + v->coords[0]= 0; + v->coords[1]= 1; + u->coords[0]= 45; + u->coords[1]= 1; + std::cout<< scalaire(u,v)< + +struct cellule { + int contenu; + cellule *suivant; +}; +struct file { + cellule *premier; + cellule *dernier; +}; + +file* init () { + file * ret = new file; + ret->premier=NULL; + ret->dernier=NULL; + return ret; +} +int cardinal ( file *w) { + int ret = 1; + if (w->premier == NULL ) return 0; + cellule * tmp = w->premier; + while ( tmp->suivant != NULL) { + tmp = tmp->suivant; + ret ++; + } + return ret; +} +bool estvide(file *w){ + return cardinal(w)==0; +} + +void ajouter(file *w, int valeur){ + cellule * tmp = new cellule; + tmp->contenu = valeur; + tmp->suivant = w->premier; + w->premier = tmp; +} + +int retire( file *w) { + int value; + cellule * ptr = w->premier; + while ( ptr->suivant->suivant != NULL) { + ptr = ptr->suivant; + } + value = ptr->suivant->contenu; + delete ptr->suivant; + ptr->suivant = NULL; + w->dernier = ptr; + return value; +} + +void retirefile ( file * w) { + while ( w->premier != NULL) { + retire(w); + } + delete w; +} + +void affichefile ( file * w ) { + cellule * ptr = w->premier; + std::cout << "\" "; + while ( ptr != NULL) { + std::cout<< ptr->contenu << " "; + ptr= ptr->suivant; + } + std::cout << " \""<< std::endl; +} + +int main () { + file * ptrfile = init(); + + std::cout << " Taille de la file : " << cardinal(ptrfile)<< std::endl; + return 0; +} diff --git a/sem_2/HLIN202/TP/TP11-12/exo5 b/sem_2/HLIN202/TP/TP11-12/exo5 new file mode 100644 index 0000000..6287485 Binary files /dev/null and b/sem_2/HLIN202/TP/TP11-12/exo5 differ diff --git a/sem_2/HLIN202/TP/TP11-12/exo5.cpp b/sem_2/HLIN202/TP/TP11-12/exo5.cpp new file mode 100644 index 0000000..24b70b7 --- /dev/null +++ b/sem_2/HLIN202/TP/TP11-12/exo5.cpp @@ -0,0 +1,49 @@ +#include + +struct CD { + int pistes; + int duree[100]; +}; + +CD cree (){ + CD disque; + return disque; +} + +void init ( CD *disque) { + std::cout<<"Entrez le nombre de pistes"<>disque->pistes; + for (int i = 0; i < disque->pistes; i++) { + std::cout<<"Entrez la duree (en secondes) de la piste numero : "<< i+1<< std::endl; + std::cin>> disque->duree[i]; + } +} +void afficheCD ( CD * disque){ + std::cout<< " Le CD est compose de " << disque->pistes << " pistes."<pistes; i ++) { + std::cout<< " "<< i + 1 << " "<duree[i]<duree ? 1 : 0; + } + return ret; +} + +int main () { + CD disque; + init(&disque); + std::cout<<"Duree totale : "<< dureetotale(disque)< +#include + + +struct s_point { + char nom; + int x,y; +}; + +struct lignepolygonale { + int nombre; + s_point *points; +}; + +double distance (s_point, s_point); +void affiche (s_point); + +double longueur ( lignepolygonale lp) { + double ret=0; + for ( int i = 0; i < lp.nombre-1; i ++) { + ret += distance (lp.points[i], lp.points[i+1]); + } + return ret; +} +lignepolygonale saisieLP () { + lignepolygonale ret; + std::cout<<"Nombre de points de la LP :"; + std::cin>>ret.nombre; + std::cout<> ret.points[i].nom; + std::cout << " Entrez les coords du point " << ret.points[i].nom << std::endl<<"x : "; + std::cin >> ret.points[i].x; + std::cout<<" y : "; + std::cin>>ret.points[i].y; + std::cout<>point.nom; + std::cout<>point.x; + std::cout << std::endl << "Saisir la coordonnee en y "; + std::cin >> point.y; + std::cout << std::endl; + if ( (int) point.nom > 90 || (int)point.nom < 65){ + std::cout<<" Saisie incorrecte"<nom = (char)0; + point->x=0; + point->y=0; +} +s_point sym ( s_point point) { + s_point ret; + ret.x= - point.x; + ret.y= -point.y; + ret.nom = (char)(65+(90-(int)point.nom)); + return ret; +} +int main () { + lignepolygonale zbeb; + zbeb=saisieLP(); + return 0; +} diff --git a/sem_2/HLIN202/TP/TP2/ex10/exo10-1 b/sem_2/HLIN202/TP/TP2/ex10/exo10-1 new file mode 100644 index 0000000..10b03c3 Binary files /dev/null and b/sem_2/HLIN202/TP/TP2/ex10/exo10-1 differ diff --git a/sem_2/HLIN202/TP/TP2/ex10/exo10-2 b/sem_2/HLIN202/TP/TP2/ex10/exo10-2 new file mode 100644 index 0000000..227f81c Binary files /dev/null and b/sem_2/HLIN202/TP/TP2/ex10/exo10-2 differ diff --git a/sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp b/sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp new file mode 100644 index 0000000..7f99fd5 --- /dev/null +++ b/sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp @@ -0,0 +1,17 @@ +#include + +int main () { + int a=0, cpt=0, som=0; + float moy=0; + std::cout<<"Entrez des entiers ( rel ), ce programme donne le nombre d'entier positifs entres avant le premier negatif"<=0 ) { + std::cin>>a; + cpt += a>=0 ? 1:0; + moy += a>0 ? a : 0; + } + moy=moy/cpt; + std::cout<<"Vous avez entre "<< cpt<< " positif avant de rentrer un negatif"< + +int main () { + int n, a; + float x,y; + std::cout<<"Entrez a et n, ce programme calcule la racine carre de a via l'algorithme de Heron D'Alexandrie, avec une precision n "<> a >>n; + x = a; + do { + y = x; + x = y/2 + a/(2*y); + std::cout< + +int main(){ + int a,b,c,min,max; + std::cout<<"Entrez 3 entiers, ce programme donnera le minimum et le maximum des trois"<> a >> b >> c; + if ( a >= b && a >= c) { + max = a; + } + else if ( b >= a && b >= c ) { + max = b; + } + else if ( c >= a && c >= b ) { + max = c; + } + if ( a <= b && a <= c ) { + min = a; + } + else if ( b <= a && b <=c ) { + min = b; + } + else if ( c <= a && c <= b ) { + min = c; + } + std::cout << "Le max est : " << max << " Le min est : " << min << std::endl; + return 0; +} diff --git a/sem_2/HLIN202/TP/TP2/ex8/exo8 b/sem_2/HLIN202/TP/TP2/ex8/exo8 new file mode 100644 index 0000000..3f2470c Binary files /dev/null and b/sem_2/HLIN202/TP/TP2/ex8/exo8 differ diff --git a/sem_2/HLIN202/TP/TP2/ex8/exo8.cpp b/sem_2/HLIN202/TP/TP2/ex8/exo8.cpp new file mode 100644 index 0000000..7caa991 --- /dev/null +++ b/sem_2/HLIN202/TP/TP2/ex8/exo8.cpp @@ -0,0 +1,13 @@ +#include + +int main () { + int x,n,reslt; + std::cout<<" Entrez x puis n, ce programme calcule la valeur de x exposant n" << std::endl; + std::cin>> x >> n; + reslt = 1; + for ( int i=0; i < n; i ++) { + reslt = x * reslt; + } + std::cout << x << " exposant " << n << " vaut : " << reslt < + +int main () { + int n; + float reslt; + std::cout << " Entrez un enter n, ce programme calcule la somme des inverses de 1 a n" << std::endl; + std::cin >> n; + for (int i=1; i <= n; i ++) { + reslt += 1.0/i; + } + std::cout<<"Le resultat est : "<< reslt < + +int main () { + int n,deb; + float reslt; + std::cout << " Entrez un enter n et i, ce programme calcule la somme des inverses de 1/i a 1/n" <> n >> deb; + for (int i=deb; i <= n; i ++) { + reslt += 1.0/i; + } + std::cout<<"Le resultat est : "<< reslt < +#include + +void triangle (int k); +int combo ( int, int); + +int main () { + triangle ( 20 ); + return 0; + +} + +void triangle ( int k ) { + int n,p,ligne; + n = 0; + p = 0; + ligne = 1; + while ( p <= k) { + while ( n <=p ) { + for ( int i=0; i < ligne; i ++) { + std::cout<< combo ( n, i ) << " "; + } + std::cout< + +double piquart ( double incert) { + int cpt=3; + bool pair = false; + double pisurquatre=1; + while ( 1/(double)cpt> incert) { + pisurquatre = pair ? pisurquatre+1 /(double)cpt : pisurquatre-1/(double)cpt; + cpt+=2; + pair = pair ? false : true; + } + return pisurquatre; +} + +int main () { + double precision; + std::cout<< " Entrez la precision ( < 1 ) a laquelle vous voulez apprecier la valeur de pi" << std::endl; + std::cin>>precision; + std::cout<< 4*piquart(precision)< + +int ackermann (int m, int n) { + int rslt=0; + if ( m == 0 && n>=0) { + rslt=n+1; + } + else if ( n==0 && m>0) { + rslt= ackermann(m-1,1); + } + else { + rslt= ackermann(m-1,ackermann(m,n-1)); + } + return rslt; +} + +int main () { + int n,m; + std::cout<<" Entrez deux nombre m et n, ce programme calcule la valeur de la fonction d'ackermann pour (m,n)"<>m>>n; + std::cout< + +int nbjourmois(int,bool); +int saisieJour(int,bool); +int saisieMois(); +int saisieAnnee(); +void affichejour(); +bool estbissextile(int); +int nbjourmois(int,bool); +int compteJours(int,int,bool); +int compteanneebissextile(int); +void codeJourAnnee(int,int,int); + +int main () { + int jour, mois, annee; + annee = saisieAnnee (); + mois= saisieMois (); + jour= saisieJour(mois, estbissextile(annee)); + codeJourAnnee(jour,mois,annee ); + return 0; +} + +int saisieJour (int mois, bool bissextile) { + int enter; + std::cout<<"Entrez le jour " << std::endl; + std::cin>>enter; + if ( enter > nbjourmois(mois, bissextile) || enter < 1) { + std::cout<< " Jour incorrect" << std::endl; + enter = saisieJour ( mois, bissextile); + } + return enter; +} + +int saisieMois () { + int enter; + std::cout<<"Entrez le mois"<>enter; + if ( enter < 1 || enter > 12 ) { + std::cout<<"Mois incorrect"<>enter; + return enter; +} + +void affichejour ( int jour) { + switch ( jour ) { + case 0 : + std::cout<<"Lundi"< 2000 ) { + rslt += estbissextile(annee) ? compteJours(jour, mois, true) : compteJours(jour, mois, false); + rslt += (annee-2000)*365 + compteanneebissextile(annee)+1; + } + else { + rslt += compteJours(jour,mois, estbissextile(annee)); + } + std::cout<<"Le "< + +bool estunenote ( float n ) { + return n <=20 && n>= 0 ? true : false; +} + +float moyenne ( int n) { + int cpt; + bool flag; + float moy, note; + cpt = 1; + flag = true; + moy = 0; + note = 0; + while ( flag && cpt <= n ) { + std::cout<<"Entrez la note numero " <>note; + moy += note; + cpt ++; + flag = estunenote(note); + } + if ( flag ) { + moy = moy/ n; + } + else { + std :: cout << " La valeur entree n'est pas une note"<> nb; +// nb=moyenne(nb); + std::cout << " La moyenne est : " << moyenne(nb)<< std::endl; + return 0; +} diff --git a/sem_2/HLIN202/TP/TP3-4/ex7/exo7 b/sem_2/HLIN202/TP/TP3-4/ex7/exo7 new file mode 100644 index 0000000..1f9f23c Binary files /dev/null and b/sem_2/HLIN202/TP/TP3-4/ex7/exo7 differ diff --git a/sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp b/sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp new file mode 100644 index 0000000..b0d86be --- /dev/null +++ b/sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp @@ -0,0 +1,34 @@ +#include +#include + +bool nombreeligible ( int n) { + int som=0,cpt =1, act=0, puiss=0; + act = n; + while ( n > 10 ) { + n= n/10; + cpt ++; + } + for ( int i=cpt; i >= 0; i--) { + puiss = (int) pow(10,i); + som += (int)pow((act/puiss)%10,3); + } + return som==act ? true : false ; +} + +bool tripleteligible ( int a, int b, int c) { + int n = a*100 + b*10 + c; + return n == pow(a,3) + pow (b,3) + pow(c,3); +} + +void testeentier () { + for (int i = 2; i < 1000; i ++) { + if(nombreeligible(i)) { + std::cout << i << std::endl; + } + } +} + +int main () { + testeentier(); + return 0; +} diff --git a/sem_2/HLIN202/TP/TP3-4/ex8/exo8 b/sem_2/HLIN202/TP/TP3-4/ex8/exo8 new file mode 100644 index 0000000..5fcea62 Binary files /dev/null and b/sem_2/HLIN202/TP/TP3-4/ex8/exo8 differ diff --git a/sem_2/HLIN202/TP/TP3-4/ex8/exo8.cpp b/sem_2/HLIN202/TP/TP3-4/ex8/exo8.cpp new file mode 100644 index 0000000..81241a7 --- /dev/null +++ b/sem_2/HLIN202/TP/TP3-4/ex8/exo8.cpp @@ -0,0 +1,25 @@ +#include + +bool estpremier ( int n) { + int cpt=2; + bool trouve= false; + while ( !trouve && cpt <= n/2 ) { + if ( n % cpt == 0) { + trouve = true; + } + cpt ++; + } + return !trouve; +} +int prochainpremier ( int n) { + while ( !estpremier(n)) { + n++; + } + return n; +} +int main () { + int n=0; + std::cin>>n; + std::cout << n << " prochain premier " << prochainpremier(n)< + +void arbre ( int base) { + if (base%2==1) { + int espaces = (base-1)/2; + int nb=1; + int etage = base / 2 +1; + for ( int i=1; i<=etage; i ++) { + for ( int j=1; j<=espaces; j ++) { + std::cout<<" "; + } + + for (int k=1; k<=nb; k ++) { + std::cout<<"*"; + } + std::cout<>n; + arbre(n); + return 0; +} 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 < + +void affichetab( int taille, int tab[]); +void inittab ( int taille, int tab[]); +void inittabsuite ( int taille, int tab[]); +int min (int a, int b); +bool prefixe ( int taille1, int taille2, int tab1[],int tab2[]); +bool tabidentique ( int taille1, int taille2, int tab1[], int tab2[]); +void bornes ( int taille, int tab[], int* max, int* min); +bool palindrome ( int taille, int tab[]); + +//determine si un tableau de caractere est un palindrome +bool palindrome ( int taille, char tab[]){ + char tabinv[taille]; + for ( int i=0; i< taille; i++){ + tabinv[i]=tab[taille-i]; + } + for ( int i =0; i= bctab[i+1] ? bctab[i]>= *max ? bctab[i] : *max : bctab[i+1]> *max ? bctab[i+1] : *max; + *min = bctab2[i] <= bctab2[i+1] ? bctab2[i]<= *min ? bctab2[i] : *min : bctab2[i+1]< *min ? bctab2[i+1] : *min; + } +} + +int main () { + // int table1[100]; + // int table2[10]; + // inittab(100, table1); + // inittabsuite(10,table2); + // affichetab(100,table1); + // affichetab(10,table2); + //int *pmin, *pmax; + //int max,min; + //pmax=&max; + //pmin=&min; + //bornes ( 100, table,pmax, pmin ); + if ( prefixe(100,10,table1,table2)) { + std::cout<<"les tableaux sont egaux"< + +int occurence ( int T[10], int x) { + int cpt=0; + for ( int i=0; i < 10; i ++) { + cpt += T[i]==x ? 1 : 0; + } + return cpt; +} +int main () { + int tab[10]= {2,3,4,2,3,1,8,2,5,9}; + int x=0; + std::cout<< " Entrez un entier positif, ce programme calcule le nombre d'occurence de cet entier dans le tableau [2 3 4 2 3 1 8 2 5 9]" << std::endl; + std::cin>>x; + std::cout< +#include + +void codbin ( int x, int tab[32]){ + for (int i=0; i < 32; i ++) { + tab[i]= x < pow(2,32-(i+1)) ? 0 : 1; + x = x < pow(2,32-(i+1)) ? x : x- pow(2,32-(i+1)); + } +} + +int main () { + int tab[32]; + int x; + std::cout<< " Entrez un nombre entier positif, ce programme calcule sa valeur en binaire sur 32 bits "<>x; + codbin(x, &tab[0]); + for (int i=0; i < 32; i ++) { + std::cout< + +int produitscal (int v[], int u[], int d) { + int ret=0; + for (int i = 0; i < d; i ++) { + ret += v[i]*u[i]; + } + return ret; +} + +int main () { + int d; + std::cout<<"entrez le nombre de composante des vecteurs" << std::endl; + std::cin >> d; + int v[d], u[d]; + for (int i=0; i < d; i ++) { + std::cout<<"Entrez la valeur "<< i+1 << " de v"<>v[i]; + } + for (int i=0; i < d; i ++ ) { + std::cout<<"Entrez la valeur "<< i+1 << " de u"<>u[i]; + } + std::cout<<"Le produit scalaire de u.v vaut " << produitscal(v,u,d) << std::endl; + return 0; + +} diff --git a/sem_2/HLIN202/TP/TP7-8/ex9/exo9 b/sem_2/HLIN202/TP/TP7-8/ex9/exo9 new file mode 100644 index 0000000..55c4d59 Binary files /dev/null and b/sem_2/HLIN202/TP/TP7-8/ex9/exo9 differ diff --git a/sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp b/sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp new file mode 100644 index 0000000..021365f --- /dev/null +++ b/sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp @@ -0,0 +1,41 @@ +#include + +void permut ( int tab[], int d, int i) { + int Temp[d]; + for (int j =0; j < d; j ++) { + Temp[j]=tab[j]; + } + if ( i > 0) { + for (int j = 0; j < d ; j ++) { + if (j-i < 0 ) { + tab[j]=Temp[d-i+j]; + } + else { + tab[j]= Temp[j-i]; + } + } + } + else if ( i < 0 ) { + for (int j = 0; j d) { + tab[j]=Temp[d-j]; + } + else { + tab[j]=Temp[j-i]; + } + } + } +} +int main () { + int tab[6] = {0,1,2,3,4,5}; + //Ce programme effectue une rotation de i etapes sur le tableau donné ( le sens change en fonction du signe de i) + permut ( tab, 6, 2); + for (int i =0; i< 6; i ++) { + std::cout< +#include +/* HLIN202 TD8 exercice du pendu +Par Gaspard Coulet ( gaspard.coulet@etu.umontpellier.fr ) +*/ + +//affiche un tableau de caractere sous la forme d'un mot +void affichechartab ( int taille, char tab[]) { + std::cout<> taille; + std::cout<<" Joueur 1 : Entrez le mot a faire deviner, puis pressez enter"<< std :: endl; + char motdev[taille+1]; + char backup[taille+1]; + for (int i=0; i < taille; i ++ ) { + std::cin>>motdev[i]; + backup[i] = motdev[i]; + } + char printed[taille+1]; + for (int i =0; i < taille; i ++) { + printed[i]= '-'; + } + system("clear"); + affichechartab(taille+1, printed); + while ( vie != 0 && justes != taille) { + std::cout << " Joueur 2 : Vous avez : " << vie << " vies; Entrez une lettre :"<> lettre; + system("clear"); + if (estdansmot(lettre, motdev, taille+1, printed, &justes)) { + system("clear"); + std::cout << " La lettre : " << lettre << " fait est bel est bien dans le mot" << std::endl; + affichechartab(taille+1,printed); + } + else { + system("clear"); + vie --; + std::cout<<" La lettre ne fait pas partie du mot, vous perdez une vie, il vous en reste : " << vie << std::endl; + affichechartab(taille+1, printed); + } + } + if ( vie == 0) { + std::cout<< " Perdu ! Le mot a deviner etait : "; + affichechartab(taille+1, backup); + } + else { + std::cout << " Bravo ! Vous avez trouve le mot :) " << std::endl<< std::endl; + } + return 0; +} diff --git a/sem_2/HLIN202/TP/TP9-10/exo b/sem_2/HLIN202/TP/TP9-10/exo new file mode 100644 index 0000000..651c6fe Binary files /dev/null and b/sem_2/HLIN202/TP/TP9-10/exo differ diff --git a/sem_2/HLIN202/TP/TP9-10/exo14/exo14 b/sem_2/HLIN202/TP/TP9-10/exo14/exo14 new file mode 100644 index 0000000..79a0305 Binary files /dev/null and b/sem_2/HLIN202/TP/TP9-10/exo14/exo14 differ diff --git a/sem_2/HLIN202/TP/TP9-10/exo14/exo14.cpp b/sem_2/HLIN202/TP/TP9-10/exo14/exo14.cpp new file mode 100644 index 0000000..da0c7c5 --- /dev/null +++ b/sem_2/HLIN202/TP/TP9-10/exo14/exo14.cpp @@ -0,0 +1,40 @@ +#include + +int * extraitpairs ( int * tab, int taille, int * taillenew) { + *taillenew=0; + for (int i = 0; i < taille; i ++){ + *taillenew += tab[i]%2==0? 1 : 0; + } + int * tabnew = new int[*taillenew]; + int j=0; + for ( int i =0; i < *taillenew; i ++ ){ + while ( tab[j] % 2!=0){ + j ++; + } + tabnew[i]= tab[j]; + j++; + } + return tabnew; +} + +void affichetab ( int *P, int taille) { +std::cout<<"["; +for ( int i =0; i + +int max ( int a, int b) { + return a>b? a : b; +} +void affichetab ( int *P, int taille) { +std::cout<<"["; +for ( int i =0; i >taille; +float *P=new float[taille]; +for(int i=0;i + +float** MatMul ( float ** m1, float ** m2, int m, int n, int p) { + float ** ret= new float*[n]; + for ( int i = 0; i>m>>n; + + float **T; + + T=MatMul(CreerMat(m,n),CreerMat(m,n), m,n,n); + afficheMat(T, m,n); + return 0; +} -- cgit v1.2.3