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/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 +++++++ 16 files changed, 341 insertions(+) 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 (limited to 'sem_2/HLIN202/TP/TP3-4') diff --git a/sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp b/sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp new file mode 100644 index 0000000..8a8b6a3 --- /dev/null +++ b/sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp @@ -0,0 +1,33 @@ +#include +#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; +} -- cgit v1.2.3