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_3/Programm/TP1/test | Bin 0 -> 9240 bytes sem_3/Programm/TP1/test.cpp | 10 + sem_3/Programm/TP2/ex1/exo | Bin 0 -> 14053 bytes sem_3/Programm/TP2/ex1/itv.cpp | 71 ++++ sem_3/Programm/TP2/ex1/itv.h | 20 ++ sem_3/Programm/TP2/ex1/jeudelaviemine/cell.cpp | 43 +++ sem_3/Programm/TP2/ex1/jeudelaviemine/cell.h | 24 ++ sem_3/Programm/TP2/ex1/jeudelaviemine/main | Bin 0 -> 13975 bytes sem_3/Programm/TP2/ex1/jeudelaviemine/main.cpp | 25 ++ sem_3/Programm/TP2/ex1/main.cpp | 12 + sem_3/Programm/TP2/ex1/makefile | 4 + sem_3/Programm/TP2/exo10/exo10.c | 19 ++ sem_3/Programm/TP2/exo10/main | Bin 0 -> 8551 bytes sem_3/Programm/TP2/exo11/exo11.c | 23 ++ sem_3/Programm/TP2/exo11/main | Bin 0 -> 8651 bytes sem_3/Programm/TP2/exo13/exo13.c | 0 sem_3/Programm/TP2/exo13/impair.c | 5 + sem_3/Programm/TP2/exo13/impair.h | 1 + sem_3/Programm/TP2/exo13/pair.c | 4 + sem_3/Programm/TP2/exo13/pair.h | 1 + sem_3/Programm/TP2/exo13/spair | Bin 0 -> 8695 bytes sem_3/Programm/TP2/exo13/spair.c | 11 + sem_3/Programm/cours-hlin302.pdf | Bin 0 -> 1960924 bytes sem_3/Programm/jeu_de_la_vie/JDV0-bis-main.cpp | 14 + sem_3/Programm/jeu_de_la_vie/JDV0-bis.cpp | 149 +++++++++ sem_3/Programm/jeu_de_la_vie/JDV0-bis.h | 38 +++ sem_3/Programm/jeu_de_la_vie/arch/population.cpp | 145 +++++++++ sem_3/Programm/jeu_de_la_vie/arch/population.h | 53 +++ .../jeu_de_la_vie/arch/population_vivante.cpp | 42 +++ .../jeu_de_la_vie/arch/population_vivante.h | 18 ++ sem_3/Programm/jeu_de_la_vie/cellule.cpp | 95 ++++++ sem_3/Programm/jeu_de_la_vie/cellule.h | 55 ++++ sem_3/Programm/jeu_de_la_vie/option.cpp | 45 +++ sem_3/Programm/jeu_de_la_vie/option.h | 47 +++ .../jeu_de_la_vie/population-vivante-v2.cpp | 184 +++++++++++ .../Programm/jeu_de_la_vie/population-vivante-v2.h | 60 ++++ sem_3/Programm/jeu_de_la_vie/tabOptions.cpp | 58 ++++ sem_3/Programm/jeu_de_la_vie/tabOptions.h | 22 ++ sem_3/SYSTEME/TP1/JelesAime | 1 + sem_3/SYSTEME/TP1/mesChanteursPreferes | 1 + sem_3/SYSTEME/TP2/ex6/param | Bin 0 -> 8571 bytes sem_3/SYSTEME/TP2/ex6/param.c | 12 + sem_3/SYSTEME/TP2/ex7/moyenne | Bin 0 -> 8573 bytes sem_3/SYSTEME/TP2/ex7/moyenne.c | 14 + sem_3/SYSTEME/TP2/ex9/strsplit | Bin 0 -> 8715 bytes sem_3/SYSTEME/TP2/ex9/strsplit.c | 54 ++++ sem_3/SYSTEME/TP2/impair.c | 5 + sem_3/SYSTEME/TP2/impair.h | 1 + sem_3/SYSTEME/TP2/pair.c | 4 + sem_3/SYSTEME/TP2/pair.h | 1 + sem_3/SYSTEME/TP2/spair | Bin 0 -> 8695 bytes sem_3/SYSTEME/TP2/spair.c | 11 + sem_3/SYSTEME/TP3/HUFFMAN/Makefile | 9 + sem_3/SYSTEME/TP3/HUFFMAN/compact.py | 32 ++ sem_3/SYSTEME/TP3/HUFFMAN/decompact.py | 55 ++++ sem_3/SYSTEME/TP3/HUFFMAN/dehuf.c | 150 +++++++++ sem_3/SYSTEME/TP3/HUFFMAN/distrib.c | 357 +++++++++++++++++++++ sem_3/SYSTEME/TP3/HUFFMAN/minirapport.odt | Bin 0 -> 24351 bytes sem_3/SYSTEME/TP3/HUFFMAN/readme.txt | 16 + sem_3/SYSTEME/TP4/ex22/exo | Bin 0 -> 8673 bytes sem_3/SYSTEME/TP4/ex22/exo.c | 23 ++ sem_3/SYSTEME/TP4/impair.c | 5 + sem_3/SYSTEME/TP4/impair.h | 1 + sem_3/SYSTEME/TP4/impair.o | Bin 0 -> 1432 bytes sem_3/SYSTEME/TP4/libpair.a | Bin 0 -> 2980 bytes sem_3/SYSTEME/TP4/libpair.so.1 | Bin 0 -> 7935 bytes sem_3/SYSTEME/TP4/pair.c | 4 + sem_3/SYSTEME/TP4/pair.h | 1 + sem_3/SYSTEME/TP4/pair.o | Bin 0 -> 1432 bytes sem_3/SYSTEME/TP4/spair.c | 10 + sem_3/SYSTEME/TP4/spair2 | Bin 0 -> 8695 bytes sem_3/SYSTEME/TP4/spair4 | Bin 0 -> 877305 bytes sem_3/SYSTEME/TP5/analyse_options.py | 20 ++ sem_3/SYSTEME/TP5/bonjour_v1.py | 3 + sem_3/SYSTEME/TP6/comptagefichier.py | 30 ++ sem_3/SiteWeb/index.html | 21 ++ sem_3/SiteWeb/photo.png | Bin 0 -> 223287 bytes sem_3/SiteWeb/photo1.png | Bin 0 -> 603401 bytes sem_3/SiteWeb/photo2.png | Bin 0 -> 350476 bytes sem_3/SiteWeb/photo3.png | Bin 0 -> 1404244 bytes sem_3/SiteWeb/photo4.png | Bin 0 -> 16744 bytes sem_3/SiteWeb/photo5.jpg | Bin 0 -> 345689 bytes sem_3/SiteWeb/photo5.png | Bin 0 -> 1972709 bytes sem_3/SiteWeb/style.css | 103 ++++++ sem_3/SiteWeb/tp1/Thumbs.db | Bin 0 -> 15872 bytes sem_3/SiteWeb/tp1/index.html | 43 +++ sem_3/SiteWeb/tp1/photo1.jpg | Bin 0 -> 85333 bytes sem_3/SiteWeb/tp1/photo2.jpg | Bin 0 -> 480093 bytes sem_3/SiteWeb/tp1/phototable.png | Bin 0 -> 19646 bytes sem_3/SiteWeb/tp1/pp.html | 47 +++ sem_3/SiteWeb/tp1/table.html | 49 +++ sem_3/SiteWeb/tp2/ImageCassoulet.jpg | Bin 0 -> 124856 bytes sem_3/SiteWeb/tp2/Thumbs.db | Bin 0 -> 11264 bytes sem_3/SiteWeb/tp2/base.css | 21 ++ sem_3/SiteWeb/tp2/base.html | 84 +++++ sem_3/SiteWeb/tp2/cassoulet.css | 35 ++ sem_3/SiteWeb/tp2/cassoulet.html | 84 +++++ sem_3/SiteWeb/tp2/cassoulet.jpg | Bin 0 -> 12685 bytes sem_3/SiteWeb/tp2/index.html | 65 ++++ sem_3/SiteWeb/tp2/photobase.png | Bin 0 -> 172619 bytes sem_3/SiteWeb/tp3/index.html | 25 ++ sem_3/SiteWeb/tp3/texte.tar | Bin 0 -> 61440 bytes sem_3/SiteWeb/tp4/calc.tar | Bin 0 -> 102400 bytes sem_3/SiteWeb/tp4/index.html | 17 + sem_3/SiteWeb/tp5/exo1.odp | Bin 0 -> 3125950 bytes sem_3/SiteWeb/tp5/index.html | 21 ++ sem_3/algo/TP3/FichiersTP3.tgz | Bin 0 -> 2607 bytes sem_3/algo/TP3/enonceTP3.pdf | Bin 0 -> 125909 bytes sem_3/algo/TP3/fichierTP3.cpp | 127 ++++++++ sem_3/algo/TP3/fichierTP3.h | 43 +++ sem_3/algo/TP3/mainTP3.cpp | 84 +++++ sem_3/algo/TP3/progListeSC.cpp | 105 ++++++ sem_3/algo/TP3/progListeSC.h | 56 ++++ sem_3/algo/TP3/tp3 | Bin 0 -> 19624 bytes sem_3/algo/TP4/fichierTP4.cpp | 194 +++++++++++ sem_3/algo/TP4/progListeSC.cpp | 114 +++++++ sem_3/algo/TP4/progListeSC.h | 59 ++++ sem_3/algo/TP4/tpIN301_4.pdf | Bin 0 -> 94341 bytes sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp | 65 ++++ sem_3/algo/tp1-done/PROG_TP1/outilsTab.cpp | 131 ++++++++ sem_3/algo/tp1-done/PROG_TP1/outilsTab.h | 74 +++++ sem_3/algo/tp1-done/PROG_TP1/sm1.dat | 10 + sem_3/algo/tp1-done/PROG_TP1/sm2.dat | 7 + sem_3/algo/tp1-done/PROG_TP1/sm3.dat | 10 + sem_3/algo/tp1-done/PROG_TP1/sm4.dat | 10 + sem_3/algo/tp1-done/PROG_TP1/tp1 | Bin 0 -> 19257 bytes sem_3/algo/tp1-done/PROG_TP1/trace1.gnu | 5 + sem_3/algo/tp1-done/PROG_TP1/trace2.gnu | 5 + sem_3/algo/tp1-done/PROG_TP1/trace3.gnu | 5 + "sem_3/algo/tp1-done/\303\251nonc\303\251TP1.pdf" | Bin 0 -> 99901 bytes sem_3/algo/tp2/fichierTP2.cpp | 214 ++++++++++++ sem_3/algo/tp2/prog | Bin 0 -> 19149 bytes sem_3/algo/tp2/progListeSC.cpp | 104 ++++++ sem_3/algo/tp2/progListeSC.h | 56 ++++ "sem_3/algo/tp2/\303\251nonc\303\251 TP2.pdf" | Bin 0 -> 100541 bytes .../SujetBatailleNavale.pdf | Bin 0 -> 606274 bytes .../Documents du Projet-20171011/test-piece.cpp | 65 ++++ .../Documents du Projet-20171011/window.cpp | 114 +++++++ .../project/Documents du Projet-20171011/window.h | 85 +++++ 139 files changed, 4475 insertions(+) create mode 100644 sem_3/Programm/TP1/test create mode 100644 sem_3/Programm/TP1/test.cpp create mode 100644 sem_3/Programm/TP2/ex1/exo create mode 100644 sem_3/Programm/TP2/ex1/itv.cpp create mode 100644 sem_3/Programm/TP2/ex1/itv.h create mode 100644 sem_3/Programm/TP2/ex1/jeudelaviemine/cell.cpp create mode 100644 sem_3/Programm/TP2/ex1/jeudelaviemine/cell.h create mode 100644 sem_3/Programm/TP2/ex1/jeudelaviemine/main create mode 100644 sem_3/Programm/TP2/ex1/jeudelaviemine/main.cpp create mode 100644 sem_3/Programm/TP2/ex1/main.cpp create mode 100644 sem_3/Programm/TP2/ex1/makefile create mode 100644 sem_3/Programm/TP2/exo10/exo10.c create mode 100644 sem_3/Programm/TP2/exo10/main create mode 100644 sem_3/Programm/TP2/exo11/exo11.c create mode 100644 sem_3/Programm/TP2/exo11/main create mode 100644 sem_3/Programm/TP2/exo13/exo13.c create mode 100644 sem_3/Programm/TP2/exo13/impair.c create mode 100644 sem_3/Programm/TP2/exo13/impair.h create mode 100644 sem_3/Programm/TP2/exo13/pair.c create mode 100644 sem_3/Programm/TP2/exo13/pair.h create mode 100644 sem_3/Programm/TP2/exo13/spair create mode 100644 sem_3/Programm/TP2/exo13/spair.c create mode 100644 sem_3/Programm/cours-hlin302.pdf create mode 100644 sem_3/Programm/jeu_de_la_vie/JDV0-bis-main.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/JDV0-bis.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/JDV0-bis.h create mode 100644 sem_3/Programm/jeu_de_la_vie/arch/population.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/arch/population.h create mode 100644 sem_3/Programm/jeu_de_la_vie/arch/population_vivante.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/arch/population_vivante.h create mode 100644 sem_3/Programm/jeu_de_la_vie/cellule.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/cellule.h create mode 100644 sem_3/Programm/jeu_de_la_vie/option.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/option.h create mode 100644 sem_3/Programm/jeu_de_la_vie/population-vivante-v2.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/population-vivante-v2.h create mode 100644 sem_3/Programm/jeu_de_la_vie/tabOptions.cpp create mode 100644 sem_3/Programm/jeu_de_la_vie/tabOptions.h create mode 100644 sem_3/SYSTEME/TP1/JelesAime create mode 100644 sem_3/SYSTEME/TP1/mesChanteursPreferes create mode 100644 sem_3/SYSTEME/TP2/ex6/param create mode 100644 sem_3/SYSTEME/TP2/ex6/param.c create mode 100644 sem_3/SYSTEME/TP2/ex7/moyenne create mode 100644 sem_3/SYSTEME/TP2/ex7/moyenne.c create mode 100644 sem_3/SYSTEME/TP2/ex9/strsplit create mode 100644 sem_3/SYSTEME/TP2/ex9/strsplit.c create mode 100644 sem_3/SYSTEME/TP2/impair.c create mode 100644 sem_3/SYSTEME/TP2/impair.h create mode 100644 sem_3/SYSTEME/TP2/pair.c create mode 100644 sem_3/SYSTEME/TP2/pair.h create mode 100644 sem_3/SYSTEME/TP2/spair create mode 100644 sem_3/SYSTEME/TP2/spair.c create mode 100644 sem_3/SYSTEME/TP3/HUFFMAN/Makefile create mode 100644 sem_3/SYSTEME/TP3/HUFFMAN/compact.py create mode 100644 sem_3/SYSTEME/TP3/HUFFMAN/decompact.py create mode 100644 sem_3/SYSTEME/TP3/HUFFMAN/dehuf.c create mode 100644 sem_3/SYSTEME/TP3/HUFFMAN/distrib.c create mode 100644 sem_3/SYSTEME/TP3/HUFFMAN/minirapport.odt create mode 100644 sem_3/SYSTEME/TP3/HUFFMAN/readme.txt create mode 100644 sem_3/SYSTEME/TP4/ex22/exo create mode 100644 sem_3/SYSTEME/TP4/ex22/exo.c create mode 100644 sem_3/SYSTEME/TP4/impair.c create mode 100644 sem_3/SYSTEME/TP4/impair.h create mode 100644 sem_3/SYSTEME/TP4/impair.o create mode 100644 sem_3/SYSTEME/TP4/libpair.a create mode 100644 sem_3/SYSTEME/TP4/libpair.so.1 create mode 100644 sem_3/SYSTEME/TP4/pair.c create mode 100644 sem_3/SYSTEME/TP4/pair.h create mode 100644 sem_3/SYSTEME/TP4/pair.o create mode 100644 sem_3/SYSTEME/TP4/spair.c create mode 100644 sem_3/SYSTEME/TP4/spair2 create mode 100644 sem_3/SYSTEME/TP4/spair4 create mode 100644 sem_3/SYSTEME/TP5/analyse_options.py create mode 100644 sem_3/SYSTEME/TP5/bonjour_v1.py create mode 100644 sem_3/SYSTEME/TP6/comptagefichier.py create mode 100644 sem_3/SiteWeb/index.html create mode 100644 sem_3/SiteWeb/photo.png create mode 100644 sem_3/SiteWeb/photo1.png create mode 100644 sem_3/SiteWeb/photo2.png create mode 100644 sem_3/SiteWeb/photo3.png create mode 100644 sem_3/SiteWeb/photo4.png create mode 100644 sem_3/SiteWeb/photo5.jpg create mode 100644 sem_3/SiteWeb/photo5.png create mode 100644 sem_3/SiteWeb/style.css create mode 100644 sem_3/SiteWeb/tp1/Thumbs.db create mode 100644 sem_3/SiteWeb/tp1/index.html create mode 100644 sem_3/SiteWeb/tp1/photo1.jpg create mode 100644 sem_3/SiteWeb/tp1/photo2.jpg create mode 100644 sem_3/SiteWeb/tp1/phototable.png create mode 100644 sem_3/SiteWeb/tp1/pp.html create mode 100644 sem_3/SiteWeb/tp1/table.html create mode 100644 sem_3/SiteWeb/tp2/ImageCassoulet.jpg create mode 100644 sem_3/SiteWeb/tp2/Thumbs.db create mode 100644 sem_3/SiteWeb/tp2/base.css create mode 100644 sem_3/SiteWeb/tp2/base.html create mode 100644 sem_3/SiteWeb/tp2/cassoulet.css create mode 100644 sem_3/SiteWeb/tp2/cassoulet.html create mode 100644 sem_3/SiteWeb/tp2/cassoulet.jpg create mode 100644 sem_3/SiteWeb/tp2/index.html create mode 100644 sem_3/SiteWeb/tp2/photobase.png create mode 100644 sem_3/SiteWeb/tp3/index.html create mode 100644 sem_3/SiteWeb/tp3/texte.tar create mode 100644 sem_3/SiteWeb/tp4/calc.tar create mode 100644 sem_3/SiteWeb/tp4/index.html create mode 100644 sem_3/SiteWeb/tp5/exo1.odp create mode 100644 sem_3/SiteWeb/tp5/index.html create mode 100644 sem_3/algo/TP3/FichiersTP3.tgz create mode 100644 sem_3/algo/TP3/enonceTP3.pdf create mode 100644 sem_3/algo/TP3/fichierTP3.cpp create mode 100644 sem_3/algo/TP3/fichierTP3.h create mode 100644 sem_3/algo/TP3/mainTP3.cpp create mode 100644 sem_3/algo/TP3/progListeSC.cpp create mode 100644 sem_3/algo/TP3/progListeSC.h create mode 100644 sem_3/algo/TP3/tp3 create mode 100644 sem_3/algo/TP4/fichierTP4.cpp create mode 100644 sem_3/algo/TP4/progListeSC.cpp create mode 100644 sem_3/algo/TP4/progListeSC.h create mode 100644 sem_3/algo/TP4/tpIN301_4.pdf create mode 100644 sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp create mode 100644 sem_3/algo/tp1-done/PROG_TP1/outilsTab.cpp create mode 100644 sem_3/algo/tp1-done/PROG_TP1/outilsTab.h create mode 100644 sem_3/algo/tp1-done/PROG_TP1/sm1.dat create mode 100644 sem_3/algo/tp1-done/PROG_TP1/sm2.dat create mode 100644 sem_3/algo/tp1-done/PROG_TP1/sm3.dat create mode 100644 sem_3/algo/tp1-done/PROG_TP1/sm4.dat create mode 100644 sem_3/algo/tp1-done/PROG_TP1/tp1 create mode 100644 sem_3/algo/tp1-done/PROG_TP1/trace1.gnu create mode 100644 sem_3/algo/tp1-done/PROG_TP1/trace2.gnu create mode 100644 sem_3/algo/tp1-done/PROG_TP1/trace3.gnu create mode 100644 "sem_3/algo/tp1-done/\303\251nonc\303\251TP1.pdf" create mode 100644 sem_3/algo/tp2/fichierTP2.cpp create mode 100644 sem_3/algo/tp2/prog create mode 100644 sem_3/algo/tp2/progListeSC.cpp create mode 100644 sem_3/algo/tp2/progListeSC.h create mode 100644 "sem_3/algo/tp2/\303\251nonc\303\251 TP2.pdf" create mode 100644 sem_3/project/Documents du Projet-20171011/SujetBatailleNavale.pdf create mode 100644 sem_3/project/Documents du Projet-20171011/test-piece.cpp create mode 100644 sem_3/project/Documents du Projet-20171011/window.cpp create mode 100644 sem_3/project/Documents du Projet-20171011/window.h (limited to 'sem_3') diff --git a/sem_3/Programm/TP1/test b/sem_3/Programm/TP1/test new file mode 100644 index 0000000..8577d4f Binary files /dev/null and b/sem_3/Programm/TP1/test differ diff --git a/sem_3/Programm/TP1/test.cpp b/sem_3/Programm/TP1/test.cpp new file mode 100644 index 0000000..91757d7 --- /dev/null +++ b/sem_3/Programm/TP1/test.cpp @@ -0,0 +1,10 @@ +#include + +int Puissance ( int x, int n) {return n==0 ? 1 : x*Puissance(x,n-1);} + +int main () { +int a,b; +std::cin >> a >> b; +std::cout << Puissance( a,b) << std::endl; +return 0; +} diff --git a/sem_3/Programm/TP2/ex1/exo b/sem_3/Programm/TP2/ex1/exo new file mode 100644 index 0000000..3c36d84 Binary files /dev/null and b/sem_3/Programm/TP2/ex1/exo differ diff --git a/sem_3/Programm/TP2/ex1/itv.cpp b/sem_3/Programm/TP2/ex1/itv.cpp new file mode 100644 index 0000000..844d859 --- /dev/null +++ b/sem_3/Programm/TP2/ex1/itv.cpp @@ -0,0 +1,71 @@ +#include +#include"itv.h" + +float Itv::lenght () { + return bornesup-borneinf; +} + +void Itv::afficher () { + std::cout<<"["<=borneinf; +} +Itv::Itv () { + borneinf =0; + bornesup = 0; +} +Itv::Itv(float a, float b) { + bornesup = b; + borneinf = a; +} +void Itv::modifborne (int i, float f) { + if (i == 0 ) { + borneinf = f; + } + else if ( i == 1) { + bornesup = f; + } + else { + std::cout<< "Borne invalide, le premier param doit valoir 0 ( pour borne inf) ou 1 ( pour borne sup)" << std::endl; + } +} + +float Itv::getborne (int i) { + if (i == 0 ) { + return borneinf; + } + else if ( i == 1) { + return bornesup; + } + else { + std::cout<< "Borne invalide, le premier param doit valoir 0 ( pour borne inf) ou 1 ( pour borne sup)" << std::endl; + return 42; + } +} + +bool Itv::estegal ( Itv inter) { + return getborne(0)==inter.getborne(0) && getborne(1) == inter.getborne(1); +} + +bool Itv::estinclusstr ( Itv inter ) { + return getborne(0) > inter.getborne(0) && getborne(1) < inter.getborne(1); +} + +bool Itv::disjoint ( Itv inter) { + return getborne(1) < inter.getborne(0) || getborne(0) > inter.getborne(1); +} + +bool Itv::accole ( Itv inter) { + return getborne(0) == inter.getborne(0) || getborne(0) == inter.getborne(1) || getborne(1) == inter.getborne(0)|| getborne(1) == inter.getborne(1); +} + +bool Itv::imbrique ( Itv inter) { + return !accole(inter) && !disjoint(inter) && !estinclusstr(inter) && !estegal(inter); +} + +void Itv::translat ( float f) { + borneinf += f; + bornesup += f; +} diff --git a/sem_3/Programm/TP2/ex1/itv.h b/sem_3/Programm/TP2/ex1/itv.h new file mode 100644 index 0000000..e8835cd --- /dev/null +++ b/sem_3/Programm/TP2/ex1/itv.h @@ -0,0 +1,20 @@ +class Itv { + private : + float borneinf, bornesup; + public : + Itv(); + Itv(float,float); + float lenght(); + void afficher(); + bool appartient(float); + void modifborne(int,float); + float getborne(int); + + bool estegal (Itv); + bool estinclusstr(Itv); + bool disjoint(Itv); + bool accole(Itv); + bool imbrique(Itv); + void translat(float); + +}; diff --git a/sem_3/Programm/TP2/ex1/jeudelaviemine/cell.cpp b/sem_3/Programm/TP2/ex1/jeudelaviemine/cell.cpp new file mode 100644 index 0000000..9c17eb7 --- /dev/null +++ b/sem_3/Programm/TP2/ex1/jeudelaviemine/cell.cpp @@ -0,0 +1,43 @@ +#include "cell.h" +#include + +void cell::setColor(color nouvelle){ + couleur = nouvelle; +} + +color cell::getColor(){ + return couleur; +} + +void cell::setVivante(bool a) { + statut = a; +} +int cell::getX () { + return x; +} + +int cell::getY () { + return y; +} +bool cell::getVivante() { + return statut; +} +void cell::printcell () { + std::cout << "La cellule ( à l'adresse mémoire " << this << " ) = {" << (statut ? "vivante" : "morte")<<", " << x << "x"< +#include"cell.h" + +bool cell_est_couleur(cell&, color); +void test_cell ( cell&); +int main ( int argc, char ** argv) { + cell cell1(1,2,true); + cell cell2(1,3,false); + std::cout<<"L'objet c1 est a l'adresse memoire" << &cell1<< std::endl; + std::cout<<"L'objet c2 est a l'adresse memoire" << &cell2<< std::endl; + test_cell(cell1); + test_cell(cell2); + std::cout<< (cell1.estvoisineenVie(cell2) ? "cell1 est voisine de cell2" : "cell1 n'est pas voisine de cell2")< +#include"itv.h" + +int main () { + Itv inter1; + Itv inter2(0,24.4); + inter1.afficher(); + inter2.afficher(); + inter2.translat(0.5); + inter2.afficher(); + return 0; +} diff --git a/sem_3/Programm/TP2/ex1/makefile b/sem_3/Programm/TP2/ex1/makefile new file mode 100644 index 0000000..fa907f2 --- /dev/null +++ b/sem_3/Programm/TP2/ex1/makefile @@ -0,0 +1,4 @@ +CC = g++ +FLAGS = -Wall +LIBS = + diff --git a/sem_3/Programm/TP2/exo10/exo10.c b/sem_3/Programm/TP2/exo10/exo10.c new file mode 100644 index 0000000..fc2f92e --- /dev/null +++ b/sem_3/Programm/TP2/exo10/exo10.c @@ -0,0 +1,19 @@ +#include +#include + +int puiss (int x, int y) { + return ( y == 0 ? 1 : x * ( puiss(x, y-1))); +} + +int main ( int argc, char ** argv) { + int lg = 0; int ret =0; + while (argv[1][lg]!=0) { + lg ++; + } + lg --; + for ( int i=lg; i >= 0; i --) { + ret += puiss(10,lg-i)*((int)(argv[1][i] )- 48); + } + printf("%d \n", ret); + return 0; +} diff --git a/sem_3/Programm/TP2/exo10/main b/sem_3/Programm/TP2/exo10/main new file mode 100644 index 0000000..a617d42 Binary files /dev/null and b/sem_3/Programm/TP2/exo10/main differ diff --git a/sem_3/Programm/TP2/exo11/exo11.c b/sem_3/Programm/TP2/exo11/exo11.c new file mode 100644 index 0000000..e0567c2 --- /dev/null +++ b/sem_3/Programm/TP2/exo11/exo11.c @@ -0,0 +1,23 @@ +#include +#include + +int puiss (int x, int y) { + return ( y == 0 ? 1 : x * ( puiss(x, y-1))); +} + +int main (int argc, char** argv) { + int ordre =1; int cp = atoi(argv[1]); int bc = cp; + while (cp / 10!= 0) { + ordre ++; + cp = cp /10; + } + printf("%d\n", ordre); + cp = bc; + char nbchar[ordre]; + for ( int i = 0; i < ordre; i ++) { + nbchar[i] = cp / puiss(10, ordre -i-1) + 48; + cp = cp % puiss(10,ordre-i -1); + } + printf("%s\n", nbchar); + return 0; +} diff --git a/sem_3/Programm/TP2/exo11/main b/sem_3/Programm/TP2/exo11/main new file mode 100644 index 0000000..3aeee19 Binary files /dev/null and b/sem_3/Programm/TP2/exo11/main differ diff --git a/sem_3/Programm/TP2/exo13/exo13.c b/sem_3/Programm/TP2/exo13/exo13.c new file mode 100644 index 0000000..e69de29 diff --git a/sem_3/Programm/TP2/exo13/impair.c b/sem_3/Programm/TP2/exo13/impair.c new file mode 100644 index 0000000..f61f5bc --- /dev/null +++ b/sem_3/Programm/TP2/exo13/impair.c @@ -0,0 +1,5 @@ +#include "pair.h" + +int impair ( unsigned int i) { + return (i == 0 ? 0 : ( pair(i-1))); +} diff --git a/sem_3/Programm/TP2/exo13/impair.h b/sem_3/Programm/TP2/exo13/impair.h new file mode 100644 index 0000000..196468b --- /dev/null +++ b/sem_3/Programm/TP2/exo13/impair.h @@ -0,0 +1 @@ +int impair(unsigned int); diff --git a/sem_3/Programm/TP2/exo13/pair.c b/sem_3/Programm/TP2/exo13/pair.c new file mode 100644 index 0000000..05b9a0a --- /dev/null +++ b/sem_3/Programm/TP2/exo13/pair.c @@ -0,0 +1,4 @@ +#include "impair.h" +int pair(unsigned int i){ + return (i == 0 ? 1 : impair(i-1)); +} diff --git a/sem_3/Programm/TP2/exo13/pair.h b/sem_3/Programm/TP2/exo13/pair.h new file mode 100644 index 0000000..2b5acab --- /dev/null +++ b/sem_3/Programm/TP2/exo13/pair.h @@ -0,0 +1 @@ +int pair ( unsigned int ); diff --git a/sem_3/Programm/TP2/exo13/spair b/sem_3/Programm/TP2/exo13/spair new file mode 100644 index 0000000..fe2dd14 Binary files /dev/null and b/sem_3/Programm/TP2/exo13/spair differ diff --git a/sem_3/Programm/TP2/exo13/spair.c b/sem_3/Programm/TP2/exo13/spair.c new file mode 100644 index 0000000..32fa224 --- /dev/null +++ b/sem_3/Programm/TP2/exo13/spair.c @@ -0,0 +1,11 @@ +#include +#include +#include "pair.h" +#include "impair.h" + +int main ( int argc, char ** argv) { + int param = atoi(argv[1]); + if (pair(param)) printf("%d est pair\n", param); + else printf("%d est impair\n", param); + return 0; +} diff --git a/sem_3/Programm/cours-hlin302.pdf b/sem_3/Programm/cours-hlin302.pdf new file mode 100644 index 0000000..12690ef Binary files /dev/null and b/sem_3/Programm/cours-hlin302.pdf differ diff --git a/sem_3/Programm/jeu_de_la_vie/JDV0-bis-main.cpp b/sem_3/Programm/jeu_de_la_vie/JDV0-bis-main.cpp new file mode 100644 index 0000000..e1ae237 --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/JDV0-bis-main.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; + +#include "JDV0-bis.h" + +int main(int argc, char** argv){ + + JeuDeLaVie JDV; + JDV.parseOptions(argc,argv); + JDV.run(4); + + return 0; +} + diff --git a/sem_3/Programm/jeu_de_la_vie/JDV0-bis.cpp b/sem_3/Programm/jeu_de_la_vie/JDV0-bis.cpp new file mode 100644 index 0000000..587c05a --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/JDV0-bis.cpp @@ -0,0 +1,149 @@ +#include "JDV0-bis.h" +#include +#include +#include +#include +using namespace std; + + +void JeuDeLaVie::nettoie(std::string &s){ + size_t pos=s.find_first_of("#"); + s=s.substr(0,pos); + int beg=0,end=s.size()-1; + while(begbeg-1 && (s[end]==' ' || s[end]=='\t' )) end--; + s=s.substr(beg,end-beg+1); +} + + +bool JeuDeLaVie::findCleVal(std::string &s, std::string &s1,std::string &s2){ + nettoie(s); + if (s==string("")) return false; + size_t pos=s.find_first_of(":"); + if (pos==string::npos) { + cerr << "Le fichier est mal formé" << endl; + terminate(); + } + s1=s.substr(0,pos); + s2=s.substr(pos+1); + nettoie(s1); + nettoie(s2); + //cerr<<"Found cle/val -> "<< s1<< " and "< "< " << (++i < argc ? argv[i] : "Erreur"); + } else { + cout << "Cette option n'a pas été reconnue."; + opt_error = true; + } + cout << endl; + } + i++; + } + if (opt_error) { + cout << "Usage : " << argv[0] << " [Options]" << endl; + opts.print(); + terminate(); + } +} diff --git a/sem_3/Programm/jeu_de_la_vie/JDV0-bis.h b/sem_3/Programm/jeu_de_la_vie/JDV0-bis.h new file mode 100644 index 0000000..763111d --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/JDV0-bis.h @@ -0,0 +1,38 @@ +#ifndef __JDV_H +#define __JDV_H + +#include "population-vivante-v2.h" +#include "tabOptions.h" + +#define HELP_ID 1 +#define VERSION_ID 2 +#define DIMENSION_ID 10 +#define PROBABILITY_ID 11 +#define CONFIG_ID 20 + + +class JeuDeLaVie { + private: + PopulationVivante POP; + TabOptions opts; + + void nettoie(std::string &s); + bool findCleVal(std::string &s, std::string &s1,std::string &s2); + void TraiteOption(const std::string &cle, const std::string &valeur, size_t num_ligne); + + public: + + JeuDeLaVie(); + + void loadConfig(std::string file); + void run(size_t); + void parseOptions(int argc, char** argv); + +}; + + + + + + +#endif diff --git a/sem_3/Programm/jeu_de_la_vie/arch/population.cpp b/sem_3/Programm/jeu_de_la_vie/arch/population.cpp new file mode 100644 index 0000000..5655e2f --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/arch/population.cpp @@ -0,0 +1,145 @@ +#include +#include +#include +#include "population.h" +using namespace std; + +#define CHECK_BOUND(i,j) \ + if (i>=N || j>=N){ \ + std::cout<<"Accessing a Cell at ("< +#include +#include +#include "population_vivante.h" + +population_vivante::population_vivante(size_t x){ + if ( x > N ) { + std::cout<<" Erreur, taille de population trop grande"< +#include +using namespace std; + +Cellule::Cellule(): age(0), x(0), y(0), couleur(NOIR) { +} + +Cellule::Cellule(bool etat, unsigned int x, unsigned int y): + age(etat ? 1 : 0), x(x), y(y), couleur(etat ? BLEU : NOIR) { +} + +bool Cellule::getVivante() const { + return age; +} + +unsigned int Cellule::getX() const { + return x; +} + +unsigned int Cellule::getY() const { + return y; +} + +Cellule::Couleur Cellule::getCouleur() const { + return couleur; +} + +// Accesseurs en écriture +void Cellule::setX(unsigned int x) { + this->x = x; +} + +void Cellule::setY(unsigned int y) { + this->y = y; +} + +bool Cellule::estVoisine(const Cellule &c) const { + return age && + ((x - c.x) * (x - c.x) + (y - c.y) * (y - c.y) <= 2); +} + +void Cellule::print() const { + std::cout<<"("< "< + +class Cellule { + public: + + enum Couleur { + NOIR, + BLEU, + VERT, + ROUGE, + JAUNE, + NB_COULEURS + }; + + private: + size_t age; + unsigned int x, y; + Couleur couleur; + + public: + + // Constructeurs + Cellule(); // morte par défaut + Cellule(bool etat, unsigned int x, unsigned int y); + + // Accesseurs en lecture + bool getVivante() const; + unsigned int getX() const; + unsigned int getY() const; + Couleur getCouleur() const; + + // Accesseurs en écriture + void setX(unsigned int x); + void setY(unsigned int y); + void setVivante(bool etat); + + // renvoie vrai si la cellule courante est vivante et est voisine de c + bool estVoisine(const Cellule &c) const; + // affiche la cellule + void print() const; + + // spécifie qu'une cellule doit mourir au prochain tour du jeu (-> changement de couleur) + void doitMourir(); +}; + +// Renvoie vrai si la cellule est de la couleur passée en paramètre, faux sinon. +bool CelluleEstDeLaCouleur(const Cellule &cellule, Cellule::Couleur couleur); + +// Retourne la chaîne correspondant à la couleur passée en paramètre +std::string Couleur2String(Cellule::Couleur c); + +#endif diff --git a/sem_3/Programm/jeu_de_la_vie/option.cpp b/sem_3/Programm/jeu_de_la_vie/option.cpp new file mode 100644 index 0000000..65d2241 --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/option.cpp @@ -0,0 +1,45 @@ +#include +#include "option.h" +#include + +using namespace std; + +/////////////////// +// Classe Option // +/////////////////// + +Option::Option(): id(-1), nom(), raccourci(), description(), type(AUCUN) {} + +Option::Option(int _id, const string &_nom, const string &_raccourci, + const string &_desc, Option::Type _type): + id(_id), nom(_nom), raccourci(_raccourci), description(_desc), type(_type) {} + +int Option::getId() const { return id; } +string Option::getName() const { return nom; } +string Option::getShortcut() const { return raccourci; } +string Option::getDescription() const { return description; } +Option::Type Option::getType() const { return type; } + +void Option::setId(int _id) { this->id = _id; } +void Option::setName(const string &name) { nom = name; } +void Option::setShortcut(const string &shortcut) { raccourci = shortcut; } +void Option::setDescription(const string &desc) { description = desc; } +void Option::setType(Option::Type t) { type = t; } + +void Option::print() const { + cout << nom << " (" << raccourci << ") " << Type2String(type) + << "\t" << description << endl; +} + +string Type2String(Option::Type t) { + string tmp; + switch (t) { + case Option::AUCUN: tmp = ""; break; + case Option::BOOLEEN: tmp = ""; break; + case Option::ENTIER: tmp = ""; break; + case Option::REEL: tmp = ""; break; + case Option::CHAR: tmp = ""; break; + case Option::CHAINE: tmp = ""; break; + } + return tmp; +} diff --git a/sem_3/Programm/jeu_de_la_vie/option.h b/sem_3/Programm/jeu_de_la_vie/option.h new file mode 100644 index 0000000..e420c4a --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/option.h @@ -0,0 +1,47 @@ +#ifndef __OPTION_H +#define __OPTION_H + +#include + +class Option { + public: + enum Type { + AUCUN, + BOOLEEN, + ENTIER, + REEL, + CHAR, + CHAINE + }; + + private: + int id; + std::string nom, raccourci, description; + Type type; + + public: + Option(); + Option(int id, const std::string &nom, const std::string &raccourci, + const std::string &desc, Type type); + + // Accesseurs en lecture + int getId() const; + std::string getName() const; + std::string getShortcut() const; + std::string getDescription() const; + Type getType() const; + + // Accesseurs en écriture + void setId(int id); + void setName(const std::string &name); + void setShortcut(const std::string &shortcut); + void setDescription(const std::string &desc); + void setType(Type t); + + // Affichage + void print() const; +}; + +std::string Type2String(Option::Type t); + +#endif diff --git a/sem_3/Programm/jeu_de_la_vie/population-vivante-v2.cpp b/sem_3/Programm/jeu_de_la_vie/population-vivante-v2.cpp new file mode 100644 index 0000000..f59cb97 --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/population-vivante-v2.cpp @@ -0,0 +1,184 @@ +#include +#include +#include +#include "population-vivante-v2.h" +using namespace std; + +#define CHECK_BOUND(i,j) \ + if (i>=N || j>=N){ \ + std::cout<<"Accessing a Cell at ("<setVivante(true); + } + } + else { + std::cerr<<"PopulationVivante: Erreur -> trop de cellule vivante pour NMAX="< +#include +#include "tabOptions.h" + +using namespace std; + +TabOptions::TabOptions(): opts(), nb_opts(0) {} + +void TabOptions::addOption(const Option &o) { + if (nb_opts == NMAX_OPTS) { + cerr << "Erreur: Impossible d'ajouter une nouvelle option." << endl + << " Nombre maximum d'option atteint"<< " (" << NMAX_OPTS << ")." + << endl; + terminate(); + } + + bool found = (getOptionIndex(o.getName()) != -1) || (getOptionIndex(o.getShortcut()) != -1); + + if (found) { + cerr << "Avertissement: L'identifiant " << o.getId() << " est déjà utilisé." + << endl; + } else { + opts[nb_opts] = o; + nb_opts++; + } +} + +void TabOptions::print() const { + cout << "Options :" << endl; + for (size_t i = 0; i < nb_opts; i++) { + opts[i].print(); + } +} + +int TabOptions::getOptionIndex(const string &opt) const { + bool found = false; + size_t i = 0; + while (!found && (i < nb_opts)) { + found = ((opts[i].getName() == opt) || (opts[i].getShortcut() == opt)); + i++; + } + return found ? i - 1 : -1; +} +// opt doit etre une option valide +int TabOptions::getOptionId(const std::string &opt) const { + int i = getOptionIndex(opt); + return (i>=0 ? opts[i].getId():-1); +} +// opt doit etre une option valide +bool TabOptions::optionHasArgument(const std::string &opt) const { + size_t i = getOptionIndex(opt); + return (opts[i].getType() != Option::AUCUN); +} +// opt doit etre une option valide +Option::Type TabOptions::optionArgumentType(const std::string &opt) const { + size_t i = getOptionIndex(opt); + return opts[i].getType(); +} diff --git a/sem_3/Programm/jeu_de_la_vie/tabOptions.h b/sem_3/Programm/jeu_de_la_vie/tabOptions.h new file mode 100644 index 0000000..cef8aaa --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/tabOptions.h @@ -0,0 +1,22 @@ +#ifndef __TABOPTIONS_H__ +#define __TABOPTIONS_H__ + +#include +#include "option.h" + +#define NMAX_OPTS 100 +class TabOptions { + private: + Option opts[NMAX_OPTS]; + size_t nb_opts; + int getOptionIndex(const std::string &opt) const; + public: + TabOptions(); + void addOption(const Option &o); + void print() const; + int getOptionId(const std::string &opt) const; + bool optionHasArgument(const std::string &opt) const; + Option::Type optionArgumentType(const std::string &opt) const; +}; + +#endif diff --git a/sem_3/SYSTEME/TP1/JelesAime b/sem_3/SYSTEME/TP1/JelesAime new file mode 100644 index 0000000..a4cd10e --- /dev/null +++ b/sem_3/SYSTEME/TP1/JelesAime @@ -0,0 +1 @@ +IM ON THE HIGHWAY TO HELL diff --git a/sem_3/SYSTEME/TP1/mesChanteursPreferes b/sem_3/SYSTEME/TP1/mesChanteursPreferes new file mode 100644 index 0000000..a4cd10e --- /dev/null +++ b/sem_3/SYSTEME/TP1/mesChanteursPreferes @@ -0,0 +1 @@ +IM ON THE HIGHWAY TO HELL diff --git a/sem_3/SYSTEME/TP2/ex6/param b/sem_3/SYSTEME/TP2/ex6/param new file mode 100644 index 0000000..944bb79 Binary files /dev/null and b/sem_3/SYSTEME/TP2/ex6/param differ diff --git a/sem_3/SYSTEME/TP2/ex6/param.c b/sem_3/SYSTEME/TP2/ex6/param.c new file mode 100644 index 0000000..c321752 --- /dev/null +++ b/sem_3/SYSTEME/TP2/ex6/param.c @@ -0,0 +1,12 @@ +#include +#include + +int main ( int argc, char **argv) { + printf("Nombre d'arguments : %d\n", argc); + int i = 1; + for (i; i < argc; i ++ ) { + printf("%s\n",argv[i]); + } +return 0; +} + diff --git a/sem_3/SYSTEME/TP2/ex7/moyenne b/sem_3/SYSTEME/TP2/ex7/moyenne new file mode 100644 index 0000000..3e75ffc Binary files /dev/null and b/sem_3/SYSTEME/TP2/ex7/moyenne differ diff --git a/sem_3/SYSTEME/TP2/ex7/moyenne.c b/sem_3/SYSTEME/TP2/ex7/moyenne.c new file mode 100644 index 0000000..6a420d8 --- /dev/null +++ b/sem_3/SYSTEME/TP2/ex7/moyenne.c @@ -0,0 +1,14 @@ +#include +#include + +int main ( int argc, char **argv) { + int i = 1; + double moy = 0; + for (i; i < argc; i ++ ) { + moy += atof(argv[i]); + } +moy = moy/(i-1); +printf("%f \n", moy ); +return 0; +} + diff --git a/sem_3/SYSTEME/TP2/ex9/strsplit b/sem_3/SYSTEME/TP2/ex9/strsplit new file mode 100644 index 0000000..65fe687 Binary files /dev/null and b/sem_3/SYSTEME/TP2/ex9/strsplit differ diff --git a/sem_3/SYSTEME/TP2/ex9/strsplit.c b/sem_3/SYSTEME/TP2/ex9/strsplit.c new file mode 100644 index 0000000..69c68e5 --- /dev/null +++ b/sem_3/SYSTEME/TP2/ex9/strsplit.c @@ -0,0 +1,54 @@ +#include +#include + +//char ** strsplit ( char*,char); +char ** strsplit ( char * fichier, char sep ) { + printf("entree dans strsplit"); + int nbsep = 0; + int cpt = 0; + while ( fichier[cpt] != '\0' ) { + nbsep += (fichier[cpt] == sep ? 1 : 0); + cpt ++; + } + printf("%d bloc differents",cpt); + int i = 0, offset = 0, offsetchar = 0; + char ** tab = malloc((cpt + 1)*sizeof(char*)) ; + printf("tab init"); + //tab[cpt] = NULL; + printf("%p", tab[cpt+1]); + for ( i =0; i < cpt+1; i ++ ) { + tab[i] = malloc ( 100 * sizeof(char)); + } + i =0; + cpt = 0; + while ( fichier[i] != '\0' ) { + if (fichier[i] != sep) { + tab[offset][offsetchar] = fichier[i]; + offsetchar ++; + cpt ++; + } + else { + tab[offset][offsetchar]='/0'; + tab[offset] = realloc ( tab[offset], (cpt) * sizeof(char)); + offset++; + offsetchar = 0; + cpt = 0 ; + } + } +return tab; +} + + +int main (int argc, char ** argv) { +int i=0,cpt=0; +printf("jusqu'ici tout va bien"); +char ** tableau = strsplit(argv[1], argv[2][0]); +while (tableau[i]!=NULL) { + while (tableau[i][cpt]!='\0') { + printf("%c",tableau[i][cpt]); + cpt ++; + } + printf("\n"); +i ++; +} +return 0;} diff --git a/sem_3/SYSTEME/TP2/impair.c b/sem_3/SYSTEME/TP2/impair.c new file mode 100644 index 0000000..f61f5bc --- /dev/null +++ b/sem_3/SYSTEME/TP2/impair.c @@ -0,0 +1,5 @@ +#include "pair.h" + +int impair ( unsigned int i) { + return (i == 0 ? 0 : ( pair(i-1))); +} diff --git a/sem_3/SYSTEME/TP2/impair.h b/sem_3/SYSTEME/TP2/impair.h new file mode 100644 index 0000000..196468b --- /dev/null +++ b/sem_3/SYSTEME/TP2/impair.h @@ -0,0 +1 @@ +int impair(unsigned int); diff --git a/sem_3/SYSTEME/TP2/pair.c b/sem_3/SYSTEME/TP2/pair.c new file mode 100644 index 0000000..05b9a0a --- /dev/null +++ b/sem_3/SYSTEME/TP2/pair.c @@ -0,0 +1,4 @@ +#include "impair.h" +int pair(unsigned int i){ + return (i == 0 ? 1 : impair(i-1)); +} diff --git a/sem_3/SYSTEME/TP2/pair.h b/sem_3/SYSTEME/TP2/pair.h new file mode 100644 index 0000000..2b5acab --- /dev/null +++ b/sem_3/SYSTEME/TP2/pair.h @@ -0,0 +1 @@ +int pair ( unsigned int ); diff --git a/sem_3/SYSTEME/TP2/spair b/sem_3/SYSTEME/TP2/spair new file mode 100644 index 0000000..fe2dd14 Binary files /dev/null and b/sem_3/SYSTEME/TP2/spair differ diff --git a/sem_3/SYSTEME/TP2/spair.c b/sem_3/SYSTEME/TP2/spair.c new file mode 100644 index 0000000..32fa224 --- /dev/null +++ b/sem_3/SYSTEME/TP2/spair.c @@ -0,0 +1,11 @@ +#include +#include +#include "pair.h" +#include "impair.h" + +int main ( int argc, char ** argv) { + int param = atoi(argv[1]); + if (pair(param)) printf("%d est pair\n", param); + else printf("%d est impair\n", param); + return 0; +} diff --git a/sem_3/SYSTEME/TP3/HUFFMAN/Makefile b/sem_3/SYSTEME/TP3/HUFFMAN/Makefile new file mode 100644 index 0000000..63886ef --- /dev/null +++ b/sem_3/SYSTEME/TP3/HUFFMAN/Makefile @@ -0,0 +1,9 @@ +all : dehuf.o huf.o + gcc -Wall -ansi -pedantic -std=c99 dehuf.o -o dehuf -lm + gcc -Wall -ansi -pedantic -std=c99 distrib.o -o huf -lm +dehuf.o : dehuf.c + gcc -Wall -ansi -pedantic -std=c99 -c dehuf.c +huf.o : distrib.c + gcc -Wall -ansi -pedantic -std=c99 -c distrib.c +clean : + rm *.o diff --git a/sem_3/SYSTEME/TP3/HUFFMAN/compact.py b/sem_3/SYSTEME/TP3/HUFFMAN/compact.py new file mode 100644 index 0000000..0d57b91 --- /dev/null +++ b/sem_3/SYSTEME/TP3/HUFFMAN/compact.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import os,sys,re +from subprocess import call + +def parcours (cible,fichierdir,init): + if os.path.isdir(cible): + liste=os.listdir(cible) + for fichier in liste : + fichier = cible+"/"+fichier + parcours(fichier,fichierdir,init) + else : + tmp = open(cible,'rb') + if init[0]=="/" : + fichierdir.write(b"\n--"+bytes(cible[len(re.search("(^\/.*\/).+",init).group(0))+1:],'UTF-8')+b"--\n") + else : + fichierdir.write(b"\n--"+bytes(cible,"UTF-8")+b"--\n") + print(cible) + byte=tmp.read() + fichierdir.write(byte) + tmp.close() + +if len(sys.argv)!= 2 : + print("Parametres incorrects, syntaxe : ./compact.py fichier\n") + exit() +cible = sys.argv[1] +fichier = open(".compactageencours",'ab') +parcours(cible,fichier,cible) +destination = re.search("(\w+\.?\w+)$",sys.argv[1]).group(1)+".comp" +call(["./huf", ".compactageencours", destination]) +call(["rm",".compactageencours"]) +fichier.close() diff --git a/sem_3/SYSTEME/TP3/HUFFMAN/decompact.py b/sem_3/SYSTEME/TP3/HUFFMAN/decompact.py new file mode 100644 index 0000000..1cc3bc3 --- /dev/null +++ b/sem_3/SYSTEME/TP3/HUFFMAN/decompact.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +import os, sys,re +from subprocess import call + +def creerdossier(path): + result =re.split("/",path) + for i in range(len(result)-1): + if i >= 1 : + result[i]= result[i-1]+"/"+result[i] + if not (os.path.exists(result[i])): + call(["mkdir",result[i]]) + +def decompactdistant(fichier, fichierdest): + os.system("./dehuf "+fichier+" > .decompactencours") + premierdos = fichierdest + call(["mkdir",premierdos]) + decompact = open(".decompactencours","r") + destfile=decompact + for line in decompact.readlines()[1:]: + tmp = line.encode() + if line[0]=="-" and line[1]=="-": + estuneentete=re.search("^--(.*)--$",line) + if estuneentete: + destfile.close() + creerdossier(premierdos+"/"+estuneentete.group(1)) + destfile=open(premierdos+"/"+estuneentete.group(1),"w") + else : + destfile.write(line) + +def decompacthere(fichier): + os.system("./dehuf "+fichier+" > .decompactencours") + premierdos = re.search("(\w+)\.?\w*.comp$",fichier).group(1) + call(["mkdir",premierdos]) + decompact = open(".decompactencours","r") + destfile=decompact + for line in decompact.readlines()[1:]: + tmp = line.encode() + if line[0]=="-" and line[1]=="-": + estuneentete=re.search("^--(.*)--$",tmp) + if estuneentete: + destfile.close() + creerdossier(premierdos+"/"+estuneentete.group(1)) + destfile=open(premierdos+"/"+estuneentete.group(1),"w") + else : + destfile.write(line) + +if len(sys.argv)==2: + decompacthere(sys.argv[1]) +elif len(sys.argv)==3: + decompactdistant(sys.argv[1],sys.argv[2]) +else: + print("Parametres incorrects, syntaxe : ./decompact.py fichiercomp [destination] \n (Destination est optionnel)") + exit() +call(["rm",".decompactencours"]) diff --git a/sem_3/SYSTEME/TP3/HUFFMAN/dehuf.c b/sem_3/SYSTEME/TP3/HUFFMAN/dehuf.c new file mode 100644 index 0000000..7b264e1 --- /dev/null +++ b/sem_3/SYSTEME/TP3/HUFFMAN/dehuf.c @@ -0,0 +1,150 @@ +#include +#include +#include + +typedef struct table table; +struct table { + unsigned int taille; + unsigned int * taillecode; + char * carac; + char ** code; +}; + +table * gettable(FILE*); +int getcarac(char *,int, table *,char *); +void getdata(FILE *, table *); +void printtabcomp ( table * ); +void supprimerTable(table * ); + + +int main ( int argc, char ** argv){ + if (argc!=2) { + printf("Nombre d'arguments incorrects, syntaxe : \"./dehuf \"fichiercomp\"\"\n"); + return 1; + } + FILE * fichier = fopen(argv[1], "rb"); + if (fichier == NULL) { + printf("Erreur, l'ouverture du fichier source à rencontré une erreur, verifiez que vous avez les droits en lecture sur le fichier.\n"); + } + table * donneecompression = gettable(fichier); + //printtabcomp(donneecompression); + getdata(fichier, donneecompression); + supprimerTable(donneecompression); + return 0; +} + + +void supprimerTable(table * tablecod){ + for (unsigned int i = 0; i < tablecod->taille; i ++){ + free(tablecod->code[i]); + } + free(tablecod->taillecode); + free(tablecod->carac); + free(tablecod); +} +table * gettable(FILE* fichier){ + int temp=0; + table * tablecodage = malloc(sizeof(table)); + tablecodage->taille = fgetc(fichier); + if (tablecodage->taille == 0) tablecodage->taille=256; + tablecodage->taillecode=malloc(sizeof(int)*tablecodage->taille); + tablecodage->carac=malloc(sizeof(char)*tablecodage->taille); + tablecodage->code=malloc(sizeof(char*)*tablecodage->taille); + int caracrestant = tablecodage->taille; + int caracint =0; + while (caracrestant>0){ + tablecodage->taillecode[tablecodage->taille-caracrestant]=fgetc(fichier); + tablecodage->code[tablecodage->taille-caracrestant]=malloc(sizeof(char)*tablecodage->taillecode[tablecodage->taille-caracrestant]); + for (int i =0; i < tablecodage->taillecode[tablecodage->taille-caracrestant] ; i ++){ + + if ( i%8 == 0){ + caracint =fgetc(fichier); + } + if (caracint >= (float)pow(2,7-(i%8))){ + tablecodage->code[tablecodage->taille-caracrestant][i]='1'; + caracint -= pow(2,7-(i%8)); + } + else { + tablecodage->code[tablecodage->taille-caracrestant][i]='0'; + } + } + temp=fgetc(fichier); + tablecodage->carac[tablecodage->taille-caracrestant]=(char)temp; + caracrestant --; + } + return tablecodage; +} +int getcarac(char * code,int taille, table * tablecodage,char * carac){ + if (taille == 0){ + return 0; + } + int i =0; + int trouve = 0; + while ( i < tablecodage->taille && !trouve){ + if (tablecodage->taillecode[i]==taille){ + int j =0; + int cestpaslui = 0; + while ( j < taille && !cestpaslui){ + if ( code[j] != tablecodage->code[i][j]){ + cestpaslui=1; + } + else j ++; + } + trouve= !cestpaslui ? 1 : 0; + } + if (!trouve) i ++; + } + if (trouve){ + *carac=tablecodage->carac[i]; + return 1; + } + else return 0; +} +void printtabcomp ( table * tabcomp){ + for (int i =0; i < tabcomp->taille; i ++){ + if (tabcomp->carac[i]==(char)10) { + printf("Carac = LF"); + } + else if (tabcomp->carac[i]==(char)13) { + printf("Carac = CR"); + } + else printf("Carac = %c", tabcomp->carac[i]); + printf(", taille chemin = %d, chemin = ", tabcomp->taillecode[i]); + for (int j =0; j < tabcomp->taillecode[i]; j ++){ + printf("%c",tabcomp->code[i][j]); + } + printf("\n"); + } +} +void getdata(FILE * fichier, table * donneecompression){ + int currentcarac=fgetc(fichier); + int nextcarac=fgetc(fichier); + int lastcarac=fgetc(fichier); + int cpt=0; + int taille=0; + char * code = malloc(0); + char carac; + int trouve=0; + while (lastcarac!=EOF){ + while ( !(trouve=getcarac(code,taille,donneecompression,&carac))/*&&lastcarac!=EOF*/){ + if ( cpt == 8){ + currentcarac=nextcarac; + nextcarac=lastcarac; + lastcarac=fgetc(fichier); + cpt =0; + } + taille ++; + code=realloc(code,sizeof(char)*taille); + if (currentcarac>=pow(2,7-cpt)){ + code[taille-1]='1'; + currentcarac-=pow(2,7-cpt); + } + else code[taille-1]='0'; + cpt ++; + } + printf("%c", carac); + taille = 0; + code=realloc(code,0); + } + printf("\n"); +} diff --git a/sem_3/SYSTEME/TP3/HUFFMAN/distrib.c b/sem_3/SYSTEME/TP3/HUFFMAN/distrib.c new file mode 100644 index 0000000..3ae45b1 --- /dev/null +++ b/sem_3/SYSTEME/TP3/HUFFMAN/distrib.c @@ -0,0 +1,357 @@ +#include +#include +#include + +typedef struct proba proba; +struct proba { + char * carac; + int * nb_carac; + float * proba; + int taille; + int somme; +}; +typedef struct branche branche; +struct branche { + char noeud; + branche * filsg; + branche * filsd; +}; +typedef struct doublet doublet; +struct doublet{ + int a; + int b; +}; +typedef struct table table; +struct table { + unsigned int taille; + unsigned int * taillecode; + char * carac; + char ** code; + unsigned int indice[256]; +}; +typedef struct buffer buffer; +struct buffer { + unsigned int taille; + char contenu; +}; + +void loading(int, FILE *,float *); +void forceprintbuffer(buffer *,FILE *); +void supprimerTable(table *); +void ecrirecomp(FILE *,FILE *,table *,buffer *,int ); +void videbuffer(buffer *); +void ajouterbuffer(buffer*, char,FILE *); +void printcaraccode(table *,char,FILE *, buffer*); +void printchemin (char *, int, FILE *, buffer *); +void parcoursarbre ( branche *, char *, int, FILE *, table *, buffer *); +table * ecrireArbre(FILE *, branche*, int,buffer *); +void afficheTab(proba *); +void supprimerArbre(branche *); +branche* creerArbre(char , branche * , branche * ); +int estdanstab (char *,int,char); +void creertab (proba *, FILE *); +branche* creerHuff(proba*); +doublet deuxpluspetits(proba *); +void aff(branche *, int ); +void printinfofinales(table *, FILE *, FILE *); + + +int main (int argc, char ** argv) { + if (argc != 3) { + printf("Erreur, la syntaxe est la suivante : ./huffhuff [source] [destination]"); + return -1; + } + FILE * fichier = fopen(argv[1], "r"); + if (fichier == NULL) { + printf("Erreur, l'ouverture du fichier source à rencontré une erreur, verifiez que vous avez les droits en lecture sur le fichier."); + } + FILE * fichierdest = fopen(argv[2],"wb"); + if (fichierdest == NULL) { + printf("Erreur, l'ouverture du fichier de destination à rencontré une erreur."); + return -2; + } + fseek(fichier,0,SEEK_END); + int size = ftell(fichier); + rewind(fichier); + proba tab; + printf("Le fichier %s fait %d octets.\n",argv[1],size); + creertab (&tab, fichier); + afficheTab(&tab); + branche * Arbre = creerHuff(&tab); + free(tab.carac); + free(tab.nb_carac); + free(tab.proba); + buffer * buf = malloc(sizeof(buffer)); + videbuffer(buf); + table * tablecodage = ecrireArbre(fichierdest, Arbre, tab.taille,buf); + ecrirecomp(fichier,fichierdest,tablecodage,buf,size); + printinfofinales(tablecodage,fichier,fichierdest); + supprimerArbre(Arbre); + supprimerTable(tablecodage); + free(buf); + fclose(fichierdest); + fclose( fichier); + return 0; +} + + +void printinfofinales(table * tablecode, FILE * source, FILE * destination){ + int somme=0; + for (int i = 0; i < tablecode->taille;i++){ + somme+=tablecode->taillecode[i]; + } + float moy = (float)somme/(float)tablecode->taille; + printf("Fini ! \n"); + printf("Longueur moyenne du codage : %2.2f bits;", moy); + fseek(source,0,SEEK_END); + fseek(destination,0,SEEK_END); + int taillesource = ftell(source); + int taillecible = ftell(destination); + printf (" Taille d'origine : %d; Taille compressée : %d; Soit un gain de %3.2f %%\n", taillesource,taillecible,100-(float)taillecible*100/(float)taillesource); +} +void supprimerTable(table * tablecod){ + for (unsigned int i = 0; i < tablecod->taille; i ++){ + free(tablecod->code[i]); + } + free(tablecod->taillecode); + free(tablecod->carac); + free(tablecod); +} +void loading(int taille, FILE * fichier, float * anciennevaleur){ + int current = ftell(fichier)-1; + float avancement = current*100/taille; + if (current == 0){ + *anciennevaleur=0; + printf("["); + fflush(stdout); + } + if (*anciennevaleur+10 <= avancement){ + printf("##"); + fflush(stdout); + *anciennevaleur=avancement; + } + if (current == taille-2){ + printf("##]"); + fflush(stdout); + } + +} +void ecrirecomp(FILE * fichier,FILE * fichierdest,table * tablecodage, buffer * buf, int size){ + fseek(fichier,0,SEEK_SET); + int current=fgetc(fichier); + float * anciennevaleur=malloc(sizeof(float)); + *anciennevaleur=0; + while(current!=EOF){ + printcaraccode(tablecodage,(char)current,fichierdest,buf); + loading(size,fichier,anciennevaleur); + current =fgetc(fichier); + } + char remplissage = (char) 8-buf->taille; + forceprintbuffer(buf,fichierdest); + fwrite(&remplissage,sizeof(char),1,fichierdest); + free(buf); +} +void videbuffer(buffer * buf){ + buf->taille=0; + buf->contenu = 0; +} +void ajouterbuffer(buffer* buf, char carac,FILE * destination){ + char tmp='1'; + if ( buf->taille < 8){ + if ( carac == tmp)buf->contenu+=pow(2,7-buf->taille); + buf->taille++; + } + if (buf->taille == 8) { + fwrite(&buf->contenu,sizeof(char),1,destination); + videbuffer(buf); + fflush(destination); + } +} +void forceprintbuffer(buffer * buf,FILE * destination){ + if ( buf->taille>0){ + fwrite(&buf->contenu,sizeof(char),1,destination); + videbuffer(buf); + } +} +void printcaraccode(table* tablecodage,char carac,FILE * fichierdest, buffer * buf){ + unsigned int i =0; + i=tablecodage->indice[(unsigned char)carac]; + for (unsigned int j=0; j < tablecodage->taillecode[i];j++){ + ajouterbuffer(buf,tablecodage->code[i][j],fichierdest); + } +} +void printchemin (char * chemin, int taille, FILE *destination,buffer * buf){ + char taillechar = (char)taille; + fwrite(&taillechar, sizeof(char),1,destination); + for (int i =0; i < taille; i ++){ + ajouterbuffer(buf,chemin[i],destination); + }; + forceprintbuffer(buf, destination); +} +branche* creerHuff(proba*prob){ + branche * arbrehuf[prob->taille]; + for ( int i =0; i <= prob->taille; i ++){ + arbrehuf[i]= creerArbre(prob->carac[i], NULL, NULL); + } + doublet indices = deuxpluspetits(prob); + while (indices.b!=-1) { + arbrehuf[indices.a] = creerArbre (0, arbrehuf[indices.a],arbrehuf[indices.b]); + prob->proba[indices.a]+=prob->proba[indices.b]; + prob->proba[indices.b]=0; + indices = deuxpluspetits(prob); + } + return arbrehuf[indices.a]; +} +void parcoursarbre ( branche * Arbre, char * chemin, int taille, FILE * destination, table * tabcode, buffer * buf){ + if ( Arbre->filsd == NULL && Arbre->filsg==NULL ){ + printchemin(chemin, taille, destination, buf); + fwrite(&Arbre->noeud,sizeof(char),1,destination); + char * code = malloc(taille*sizeof(char)); + tabcode->taille+=1; + tabcode->code= realloc(tabcode->code,tabcode->taille*sizeof(char*)); + tabcode->carac=realloc(tabcode->carac,tabcode->taille*sizeof(char)); + tabcode->taillecode=realloc(tabcode->taillecode,tabcode->taille*sizeof(unsigned int)); + tabcode->carac[tabcode->taille-1]=Arbre->noeud; + tabcode->taillecode[tabcode->taille-1]=taille; + tabcode->indice[(unsigned char)Arbre->noeud]=tabcode->taille-1; + for (int i =0; i < taille; i ++){ + code[i]=chemin[i]; + } + tabcode->code[tabcode->taille-1]=code; + if (Arbre->noeud==(char)10) { + printf("Carac = LF"); + } + else if (Arbre->noeud==(char)13) { + printf("Carac = CR"); + } + else printf("Carac = %c", Arbre->noeud); + printf(", taille chemin = %d, chemin = ", taille); + for (int i =0; i < taille; i ++){ + printf("%c",chemin[i]); + } + printf("\n"); + } + else{ + int newtaille= taille + 1; + chemin = realloc(chemin, newtaille*sizeof(char)); + if (Arbre->filsg!=NULL){ + chemin[newtaille-1]='0'; + parcoursarbre ( Arbre->filsg, chemin, newtaille, destination, tabcode,buf ); + } + if (Arbre->filsd!=NULL){ + chemin[newtaille-1]='1'; + parcoursarbre ( Arbre->filsd, chemin, newtaille, destination, tabcode,buf); + } + } +} +table * ecrireArbre(FILE * destination, branche* arbre, int taille,buffer * buf){ + char taille2 = (char)taille; + table * tabcode = malloc(sizeof(table)); + tabcode->taille = 0; + tabcode->taillecode= malloc(0); + tabcode->code=malloc(0); + tabcode->carac=malloc(0); + fwrite(&taille2,sizeof(char),1,destination); + char * chemin = malloc(0); + parcoursarbre(arbre, chemin, 0, destination, tabcode,buf); + free(chemin); + fflush(destination); + return tabcode; +} +branche* creerArbre(char carac, branche * ssag, branche * ssad){ + branche * tmp = malloc(sizeof(branche)); + tmp->noeud= carac; + tmp->filsd= ssad; + tmp->filsg=ssag; + return tmp; +} +void supprimerArbre(branche * arbre){ + branche * gauche = arbre->filsg; + branche * droite = arbre->filsd; + if ( gauche != NULL){ + supprimerArbre(gauche); + } + if (droite!=NULL){ + supprimerArbre(droite); + } + if (droite==NULL && gauche == NULL) { + free(arbre); + } +} +void creertab (proba * tab, FILE * fichier){ + tab->carac = malloc(0); + tab->nb_carac = malloc (0); + tab->taille = 0; + tab->somme=0; + int caracint = 0; + char caracchar = 0; + int indice = -1; + caracint= fgetc(fichier); + while (caracint != EOF ) { + caracchar = (char)caracint; + tab->somme ++; + indice = estdanstab(tab->carac, tab->taille, caracchar); + if ( indice != -1) { + tab->nb_carac[indice]++; + } + else { + tab->taille ++; + tab->carac=realloc(tab->carac,tab->taille*(sizeof(char))); + tab->nb_carac=realloc(tab->nb_carac,tab->taille*(sizeof(int))); + tab->carac[tab->taille-1]= caracchar; + tab->nb_carac[tab->taille-1]= 1; + } + caracint = fgetc(fichier); + } + tab->proba=malloc(tab->taille*(sizeof(float))); + for (int i =0; itaille;i++){ + tab->proba[i]= (float)tab->nb_carac[i]/(float)tab->somme; + } +} +int estdanstab(char * tab, int n, char x) { + int i=0; + int ret=0; + while (itaille; i ++) { + if (prob->carac[i]==(char)10) { + printf("LF | %1.3f \n", prob->proba[i]); + } + if (prob->carac[i]==(char)13) { + printf("CR | %1.3f \n", prob->proba[i]); + } + else { + printf("%c | %1.3f \n", prob->carac[i], prob->proba[i]); + } + + } + printf("Le fichier comporte %d caracteres differents\n", prob->taille); +} +doublet deuxpluspetits(proba * prob) { //renvoie les indices des deux plus petits float du tableau + doublet ret; + ret.a= -1; + ret.b=-1; + float aval,bval; + aval = 2; + bval = 2; + for (int i =0; i< prob->taille; i ++){ + if ( prob->proba[i]!=0){ + if ( prob->proba[i]< aval){ + ret.b= ret.a; + bval=aval; + ret.a=i; + aval=prob->proba[i]; + } + else if (prob->proba[i]proba[i]; + } + } + } + return ret; +} diff --git a/sem_3/SYSTEME/TP3/HUFFMAN/minirapport.odt b/sem_3/SYSTEME/TP3/HUFFMAN/minirapport.odt new file mode 100644 index 0000000..f03ca37 Binary files /dev/null and b/sem_3/SYSTEME/TP3/HUFFMAN/minirapport.odt differ diff --git a/sem_3/SYSTEME/TP3/HUFFMAN/readme.txt b/sem_3/SYSTEME/TP3/HUFFMAN/readme.txt new file mode 100644 index 0000000..f6fd3d3 --- /dev/null +++ b/sem_3/SYSTEME/TP3/HUFFMAN/readme.txt @@ -0,0 +1,16 @@ +Compresseur Huffman de Gaspard Coulet, +"make all" pour compiler huf et dehuf, +./huf source destination +./dehuf fichiercompressé + +Pas de bug ou de soucis connu jusque là, le traitement prend apparemment un peu de temps, la faute à une optimisation peut être pas assez poussée. Le programme n'affiche pas l'arbre de huffman, car je n'ai pas eu le temps de me pencher sur la représentation +de l'arbre, en revanche, il affiche les chemin de chacun des caractères, ce qui est, en soit, une représentation de l'arbre. + +Compacteur : + +aide : + +"./compact.py source" +Compacte source dans source.comp à l'endroit ou le script est exécuté. +"./decompact.py source [destination]" +Décompacte le dossier compressé source, si destination est précisé, décompresse dedans. diff --git a/sem_3/SYSTEME/TP4/ex22/exo b/sem_3/SYSTEME/TP4/ex22/exo new file mode 100644 index 0000000..9bb5490 Binary files /dev/null and b/sem_3/SYSTEME/TP4/ex22/exo differ diff --git a/sem_3/SYSTEME/TP4/ex22/exo.c b/sem_3/SYSTEME/TP4/ex22/exo.c new file mode 100644 index 0000000..5701746 --- /dev/null +++ b/sem_3/SYSTEME/TP4/ex22/exo.c @@ -0,0 +1,23 @@ +#include +#include + +int main ( int argc, char ** argv) { + if (argc != 2) { + printf("Erreur, la syntaxe est la suivante : ./huffhuff [nomdufichier]"); + return -1; + } + FILE * fichier = fopen(argv[1], "r"); + if (fichier == NULL) { + printf("Erreur, l'ouverture du fichier à rencontré une erreur, verifiez que vous avez les droits en lecture sur le fichier."); + } + int caraccount=0; + int caracint; + caracint= fgetc(fichier); + while (caracint != EOF ) { + caraccount++; + caracint = fgetc(fichier); + } + printf("%d\n",caraccount); + fclose(fichier); + return 0; +} diff --git a/sem_3/SYSTEME/TP4/impair.c b/sem_3/SYSTEME/TP4/impair.c new file mode 100644 index 0000000..f61f5bc --- /dev/null +++ b/sem_3/SYSTEME/TP4/impair.c @@ -0,0 +1,5 @@ +#include "pair.h" + +int impair ( unsigned int i) { + return (i == 0 ? 0 : ( pair(i-1))); +} diff --git a/sem_3/SYSTEME/TP4/impair.h b/sem_3/SYSTEME/TP4/impair.h new file mode 100644 index 0000000..196468b --- /dev/null +++ b/sem_3/SYSTEME/TP4/impair.h @@ -0,0 +1 @@ +int impair(unsigned int); diff --git a/sem_3/SYSTEME/TP4/impair.o b/sem_3/SYSTEME/TP4/impair.o new file mode 100644 index 0000000..c243e3c Binary files /dev/null and b/sem_3/SYSTEME/TP4/impair.o differ diff --git a/sem_3/SYSTEME/TP4/libpair.a b/sem_3/SYSTEME/TP4/libpair.a new file mode 100644 index 0000000..b9799de Binary files /dev/null and b/sem_3/SYSTEME/TP4/libpair.a differ diff --git a/sem_3/SYSTEME/TP4/libpair.so.1 b/sem_3/SYSTEME/TP4/libpair.so.1 new file mode 100644 index 0000000..1f7fd3d Binary files /dev/null and b/sem_3/SYSTEME/TP4/libpair.so.1 differ diff --git a/sem_3/SYSTEME/TP4/pair.c b/sem_3/SYSTEME/TP4/pair.c new file mode 100644 index 0000000..05b9a0a --- /dev/null +++ b/sem_3/SYSTEME/TP4/pair.c @@ -0,0 +1,4 @@ +#include "impair.h" +int pair(unsigned int i){ + return (i == 0 ? 1 : impair(i-1)); +} diff --git a/sem_3/SYSTEME/TP4/pair.h b/sem_3/SYSTEME/TP4/pair.h new file mode 100644 index 0000000..2b5acab --- /dev/null +++ b/sem_3/SYSTEME/TP4/pair.h @@ -0,0 +1 @@ +int pair ( unsigned int ); diff --git a/sem_3/SYSTEME/TP4/pair.o b/sem_3/SYSTEME/TP4/pair.o new file mode 100644 index 0000000..7f6ccff Binary files /dev/null and b/sem_3/SYSTEME/TP4/pair.o differ diff --git a/sem_3/SYSTEME/TP4/spair.c b/sem_3/SYSTEME/TP4/spair.c new file mode 100644 index 0000000..410bcbf --- /dev/null +++ b/sem_3/SYSTEME/TP4/spair.c @@ -0,0 +1,10 @@ +#include +#include +#include"pair.h" +#include"impair.h" +int main ( int argc, char ** argv) { + int param = atoi(argv[1]); + if (pair(param)) printf("%d est pair\n", param); + else printf("%d est impair\n", param); + return 0; +} diff --git a/sem_3/SYSTEME/TP4/spair2 b/sem_3/SYSTEME/TP4/spair2 new file mode 100644 index 0000000..fe2dd14 Binary files /dev/null and b/sem_3/SYSTEME/TP4/spair2 differ diff --git a/sem_3/SYSTEME/TP4/spair4 b/sem_3/SYSTEME/TP4/spair4 new file mode 100644 index 0000000..43441e1 Binary files /dev/null and b/sem_3/SYSTEME/TP4/spair4 differ diff --git a/sem_3/SYSTEME/TP5/analyse_options.py b/sem_3/SYSTEME/TP5/analyse_options.py new file mode 100644 index 0000000..27c195b --- /dev/null +++ b/sem_3/SYSTEME/TP5/analyse_options.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +import sys +import re +import os +if len(sys.argv) != 2 : + print("Options incorectes") +os.getenv("HOME") +fd = open("/home/Lenain/.bashrc","r") +content = fd.readlines() +fd.close() +for lines in content : + if re.search("^-",sys.argv[1]) : + if re.search("a",sys.argv[1]) : + opta = re.search("^[\t ]*alias[ \t]*(\w+)=(.+)", lines) + if opta : + print(opta.group(1),"=", opta.group(2)) + if re.search("p",sys.argv[1]) : + opta = re.search("^PATH=$PATH:(.*)", lines) + if opta : + print(opta.group(1)) diff --git a/sem_3/SYSTEME/TP5/bonjour_v1.py b/sem_3/SYSTEME/TP5/bonjour_v1.py new file mode 100644 index 0000000..a877b61 --- /dev/null +++ b/sem_3/SYSTEME/TP5/bonjour_v1.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 +import sys +print("Bonjour", sys.argv[1],"!") diff --git a/sem_3/SYSTEME/TP6/comptagefichier.py b/sem_3/SYSTEME/TP6/comptagefichier.py new file mode 100644 index 0000000..6b97463 --- /dev/null +++ b/sem_3/SYSTEME/TP6/comptagefichier.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import os, sys,re +listetypefichier = {}; +def parcours (repertoire): + print("Je suis dans "+repertoire) + liste=os.listdir(repertoire) + for fichier in liste : + fichier = repertoire+"/"+fichier + if os.path.isdir(fichier): + parcours(fichier) + else : + recherche = re.search("(\.\w+)$", fichier) + if recherche : + if recherche.group(1) in listetypefichier : + listetypefichier[recherche.group(1)]+=1 + else : + listetypefichier[recherche.group(1)]=1; + else : + if "pas de suffixe" in listetypefichier : + listetypefichier["pas de suffixe"]+=1 + else : + listetypefichier["pas de suffixe"]=1 + +parcours(sys.argv[1]) +total = 0; +for cle in listetypefichier.keys() : + print(cle+" : ", listetypefichier[cle]) + total += listetypefichier[cle] +print("TOTAL : ",total) diff --git a/sem_3/SiteWeb/index.html b/sem_3/SiteWeb/index.html new file mode 100644 index 0000000..370365f --- /dev/null +++ b/sem_3/SiteWeb/index.html @@ -0,0 +1,21 @@ + + + + + + Gaspard Coulet + + + +

Site Web réalisé dans le cadre de l'enseignement de culture generale
outils de base en informatique

+
+ Image du premer site web realisé en TPTP1 + Image du second site web realisé en TPTP2 + Image d'une des page traitement de texte realisées en TPTP3 + Image des classeurs realisés en TPTP4 + Image du diapo realisée en TPTP5 +
+

+ + + diff --git a/sem_3/SiteWeb/photo.png b/sem_3/SiteWeb/photo.png new file mode 100644 index 0000000..8ed1b43 Binary files /dev/null and b/sem_3/SiteWeb/photo.png differ diff --git a/sem_3/SiteWeb/photo1.png b/sem_3/SiteWeb/photo1.png new file mode 100644 index 0000000..394fd84 Binary files /dev/null and b/sem_3/SiteWeb/photo1.png differ diff --git a/sem_3/SiteWeb/photo2.png b/sem_3/SiteWeb/photo2.png new file mode 100644 index 0000000..87fdde8 Binary files /dev/null and b/sem_3/SiteWeb/photo2.png differ diff --git a/sem_3/SiteWeb/photo3.png b/sem_3/SiteWeb/photo3.png new file mode 100644 index 0000000..ddfefb7 Binary files /dev/null and b/sem_3/SiteWeb/photo3.png differ diff --git a/sem_3/SiteWeb/photo4.png b/sem_3/SiteWeb/photo4.png new file mode 100644 index 0000000..9bdcfa9 Binary files /dev/null and b/sem_3/SiteWeb/photo4.png differ diff --git a/sem_3/SiteWeb/photo5.jpg b/sem_3/SiteWeb/photo5.jpg new file mode 100644 index 0000000..53695c3 Binary files /dev/null and b/sem_3/SiteWeb/photo5.jpg differ diff --git a/sem_3/SiteWeb/photo5.png b/sem_3/SiteWeb/photo5.png new file mode 100644 index 0000000..21c1261 Binary files /dev/null and b/sem_3/SiteWeb/photo5.png differ diff --git a/sem_3/SiteWeb/style.css b/sem_3/SiteWeb/style.css new file mode 100644 index 0000000..afef246 --- /dev/null +++ b/sem_3/SiteWeb/style.css @@ -0,0 +1,103 @@ +html{ + height: 100%; +} +body { + background-color: rgb(100, 100, 100); + position: relative; + height: 100%; +} +.Cadre { + background-color: rgb(50,50,50); + border-radius: 10px; + width:75%; + text-align:left; + margin:auto; + margin-top: 2%; + padding:1% 1% 1% 1%; + color:White; +} +.image { + width: 97%; + margin-top : 2%; +} +footer { + text-align:left; + position: absolute; + color:White; + left:0; + width: 99.5%; + margin-top:2%; + background-color: rgb(30,30,30); + border-radius:10px; + padding-left:1%; +} +.lien { + display: inline-block; + width: 17%; + height: 98%; + text-align: center; + padding: auto; + margin: 1% 1% 1% 1%; + background-color: rgb(30,30,30); + border-radius: 5px; +} +.lientp1 { + display: inline-block; + width: 30%; + height: 98%; + text-align: center; + padding: auto; + margin: 1% 1% 1% 1%; + background-color: rgb(30,30,30); + border-radius: 5px; +} +.lientp2 { + display: inline-block; + width: 30%; + height: 98%; + text-align: center; + padding: auto; + margin: 1% 1% 1% 1%; + background-color: rgb(30,30,30); + border-radius: 5px; +} +.lientp3 { + display: inline-block; + width: 47%; + height: 98%; + text-align: center; + padding: auto; + margin: 1% 1% 1% 1%; + background-color: rgb(30,30,30); + border-radius: 5px; +} +.lientp4 { + display: inline-block; + width: 47%; + height: 98%; + text-align: center; + padding: auto; + margin: 1% 1% 1% 1%; + background-color: rgb(30,30,30); + border-radius: 5px; +} +.lientp5 { + display: inline-block; + width: 30%; + height: 98%; + text-align: center; + padding: auto; + margin: 1% 1% 1% 1%; + background-color: rgb(30,30,30); + border-radius: 5px; +} +#titre { + background-color:rgb(80,80,80); + border-radius: 10px; + margin:auto; + padding:1% 1% 1% 1%; + text-align: center; + width:66%; + color: White; + text-decoration:underline; +} diff --git a/sem_3/SiteWeb/tp1/Thumbs.db b/sem_3/SiteWeb/tp1/Thumbs.db new file mode 100644 index 0000000..8442228 Binary files /dev/null and b/sem_3/SiteWeb/tp1/Thumbs.db differ diff --git a/sem_3/SiteWeb/tp1/index.html b/sem_3/SiteWeb/tp1/index.html new file mode 100644 index 0000000..12209d4 --- /dev/null +++ b/sem_3/SiteWeb/tp1/index.html @@ -0,0 +1,43 @@ + + + + + Gaspard Coulet + + + +

TP1

+
+
+

Notes et réponses aux questions :

La commande tree affiche l'arborescence des fichiers du repertoire courant ( récursif ), avec le parametre + a, affiche aussi les fichiers cachés, avec le parametre d, affiche seulement les dossiers.

+

+ La commande cd permet de se deplacer dans le systeme de fichier. + ".." est un raccourci pour acceder au repertoire parent dans l'arborescence. + Le parametre a de la commande ls permet d'afficher les fichiers cachés. +

+ "for lettre in {a..e}; do for annee in {2010..2015}; do mkdir "archive­-$lettre-­$annee" ; done; done" + créée 25 dossiers nommés selon le type "archive-a-2010" jusqu'à "archive-e-2015". +

+ Afin de trouver un fichier commencant par la lettre a et ne comprenant pas la lettre e, on utilisera la + commande : " ls | grep ^a | grep -v e" +

+ Dans la commande "ls -a | more " affiche le contenu du repertoire courant ( fichier cachés compris ) + de maniere a le lire ligne par ligne, c'est a ce derniers effet qu'est utile la seconde partie de la commande. +

+ Dans un fichier html, la casse n'a aucune importance, le contenu de la balise title est en fait le titre de + l'onglet, les balises br sont des retours à la ligne, !... sont des commentaires, le © est le symbole + copyright, la suppression des balises fermantes html, body et head n'a aucune influence sur l'affichage de la page.

+ La suppression des balises ouvrantes n'a pas plus d'effet. + En retirant la balise fermante h2, tout le texte suivant dans la page s'affiche comme le texte originellement + present entre les deux balises. Par ailleurs, en modifiant les dimensions de la fenetre, on remarque que + la page se reorganise dynamiquement.

+ +

+ + + diff --git a/sem_3/SiteWeb/tp1/photo1.jpg b/sem_3/SiteWeb/tp1/photo1.jpg new file mode 100644 index 0000000..fde363f Binary files /dev/null and b/sem_3/SiteWeb/tp1/photo1.jpg differ diff --git a/sem_3/SiteWeb/tp1/photo2.jpg b/sem_3/SiteWeb/tp1/photo2.jpg new file mode 100644 index 0000000..4bc54ba Binary files /dev/null and b/sem_3/SiteWeb/tp1/photo2.jpg differ diff --git a/sem_3/SiteWeb/tp1/phototable.png b/sem_3/SiteWeb/tp1/phototable.png new file mode 100644 index 0000000..4d84ed9 Binary files /dev/null and b/sem_3/SiteWeb/tp1/phototable.png differ diff --git a/sem_3/SiteWeb/tp1/pp.html b/sem_3/SiteWeb/tp1/pp.html new file mode 100644 index 0000000..0320eae --- /dev/null +++ b/sem_3/SiteWeb/tp1/pp.html @@ -0,0 +1,47 @@ + + +Ceci est un test d'HLSE305 + + + +

Page Personnelle

+
+ +

Pour le site de la fac, Cliquez ici

+

Pour m'envoyer un mail, Cliquez ici

+

+Titre Principal +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus accumsan ultrices scelerisque. Integer laoreet aliquam nulla, ut lacinia enim tincidunt eu. Vestibulum egestas ligula turpis, et feugiat mi finibus id. Nunc ipsum lacus, finibus varius interdum consequat, vulputate sit amet nulla. Aliquam quis gravida sem. Sed elementum, nunc sed dictum consequat, dui nunc tempor velit, vel accumsan ex felis sed ipsum. Integer semper orci erat, vel pharetra ante sagittis nec. Proin volutpat interdum mi, sit amet suscipit ex mattis vitae. Nullam suscipit eget velit in ultrices. In pellentesque at lorem eu finibus. In vulputate egestas lorem, quis commodo nisl iaculis at. Aenean at velit mattis, volutpat tellus et, luctus lectus. Cras bibendum et nunc rutrum tincidunt. +

+ +

+Titre secondaire +In quis egestas metus, nec malesuada orci. Quisque ac tempor odio. Pellentesque convallis malesuada bibendum. Aenean imperdiet rutrum ultricies. In leo urna, auctor vel elit quis, accumsan convallis augue. Maecenas non turpis lacinia, malesuada dolor a, imperdiet purus. Suspendisse condimentum tortor at consequat malesuada. +

+

+Titre secondaire +Quisque gravida dictum sagittis. Phasellus laoreet tellus ligula, fermentum porta dolor lobortis ac. Vestibulum eget porttitor magna. Duis lobortis mauris et justo pretium, laoreet viverra lorem pulvinar. Aenean sagittis ultrices fermentum. In hac habitasse platea dictumst. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse sit amet nisi non lorem hendrerit dictum. Aenean tincidunt erat ac lacus commodo interdum sit amet et magna. Aenean eu nulla accumsan, vestibulum neque id, tincidunt velit. Aenean vel mi ipsum. Integer in augue justo. Aenean bibendum dignissim ligula. Suspendisse diam nisl, tincidunt vel nibh nec, tincidunt venenatis arcu. +

+ +

+Titre secondaire +Nulla nec lorem vel felis finibus imperdiet. Donec congue eleifend quam, a pretium libero sagittis a. Donec vel libero vel risus dictum rutrum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eros arcu, dignissim quis tellus vitae, cursus viverra metus. Duis efficitur, turpis nec rutrum fringilla, lacus sem viverra massa, a faucibus lectus diam non sapien. Nullam eget neque efficitur est tincidunt mattis eget at lacus. Duis eleifend eros neque, ac feugiat felis sodales nec. Aenean vitae nisi vulputate, malesuada velit eu, sagittis libero. Etiam volutpat vulputate quam ut tempus. Ut nec tempor dui. +

+ +

+Titre secondaire +Cras vitae neque sapien. Ut lobortis ligula ac aliquam sagittis. Aliquam quis porttitor risus. Duis faucibus varius tellus, in tincidunt ipsum auctor a. Ut condimentum magna at dui faucibus, quis congue ipsum suscipit. Nam vitae suscipit erat, id maximus mauris. Etiam sollicitudin nunc justo, elementum porta elit dapibus id. Nullam nibh elit, fringilla eu nulla vitae, tincidunt posuere ex. Morbi congue elit id ligula accumsan blandit. Integer cursus vitae neque at sodales. Aenean quis ante magna. Mauris accumsan commodo purus, ac bibendum erat tempus quis. Mauris facilisis volutpat tellus, id volutpat lectus feugiat nec. +

+ +

[NH4]+

+

Page Composée par moi-même.
+

+Vous pouvez m'écrire à cette adresse.

+
©2015
+ diff --git a/sem_3/SiteWeb/tp1/table.html b/sem_3/SiteWeb/tp1/table.html new file mode 100644 index 0000000..da726d2 --- /dev/null +++ b/sem_3/SiteWeb/tp1/table.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Preferences
Kumquats frais Kumquats au sirop
Sexe
Hommes de moins de 18 ans45% 55%
Hommes de plus de 18 ans51% 49%
Femmes de moins de 18 ans 56% 44%
Femmes de plus de 18 ans63% 37%
+ + diff --git a/sem_3/SiteWeb/tp2/ImageCassoulet.jpg b/sem_3/SiteWeb/tp2/ImageCassoulet.jpg new file mode 100644 index 0000000..5dcc385 Binary files /dev/null and b/sem_3/SiteWeb/tp2/ImageCassoulet.jpg differ diff --git a/sem_3/SiteWeb/tp2/Thumbs.db b/sem_3/SiteWeb/tp2/Thumbs.db new file mode 100644 index 0000000..3088411 Binary files /dev/null and b/sem_3/SiteWeb/tp2/Thumbs.db differ diff --git a/sem_3/SiteWeb/tp2/base.css b/sem_3/SiteWeb/tp2/base.css new file mode 100644 index 0000000..dbfc7f4 --- /dev/null +++ b/sem_3/SiteWeb/tp2/base.css @@ -0,0 +1,21 @@ +body { + background-color:dimgray; +} +div.div1 { + background-color: #FF0000; + padding: 3px 5px 3px 5px; +} +div.div2 { + background-color: #00FF00; + padding: 3px 5px 3px 5px; +} +div.div3 { + background-color: #0000FF; + padding: 3px 5px 3px 5px; + border-style:solid; + border-width:2px; +} +div.div4 { + background-color: #007777; + padding: 3px 5px 3px 5px; +} diff --git a/sem_3/SiteWeb/tp2/base.html b/sem_3/SiteWeb/tp2/base.html new file mode 100644 index 0000000..9c49eff --- /dev/null +++ b/sem_3/SiteWeb/tp2/base.html @@ -0,0 +1,84 @@ + + + + + +

+ I
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem +accusantium doloremque laudantium, +totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et +quasi architecto beatae vitae dicta sunt explicabo. + Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut +fugit, sed quia consequuntur magni dolores +eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, +qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, + sed quia non numquam eius modi tempora incidunt ut labore et dolore +magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, +quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi +ut aliquid ex ea commodi consequatur? Quis autem vel eum iure + reprehenderit qui in ea voluptate velit esse quam nihil molestiae +consequatur, vel illum qui dolorem eum +fugiat quo voluptas nulla pariatur?

+
+ + +

+ II
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem +accusantium doloremque laudantium, +totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et +quasi architecto beatae vitae dicta sunt explicabo. + Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut +fugit, sed quia consequuntur magni dolores +eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, +qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, + sed quia non numquam eius modi tempora incidunt ut labore et dolore +magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, +quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi +ut aliquid ex ea commodi consequatur? Quis autem vel eum iure + reprehenderit qui in ea voluptate velit esse quam nihil molestiae +consequatur, vel illum qui dolorem eum +fugiat quo voluptas nulla pariatur?

+
+ +

+ III
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem +accusantium doloremque laudantium, +totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et +quasi architecto beatae vitae dicta sunt explicabo. + Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut +fugit, sed quia consequuntur magni dolores +eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, +qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, + sed quia non numquam eius modi tempora incidunt ut labore et dolore +magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, +quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi +ut aliquid ex ea commodi consequatur? Quis autem vel eum iure + reprehenderit qui in ea voluptate velit esse quam nihil molestiae +consequatur, vel illum qui dolorem eum +fugiat quo voluptas nulla pariatur?

+
+ +

+ IV
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem +accusantium doloremque laudantium, +totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et +quasi architecto beatae vitae dicta sunt explicabo. + Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut +fugit, sed quia consequuntur magni dolores +eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, +qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, + sed quia non numquam eius modi tempora incidunt ut labore et dolore +magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, +quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi +ut aliquid ex ea commodi consequatur? Quis autem vel eum iure + reprehenderit qui in ea voluptate velit esse quam nihil molestiae +consequatur, vel illum qui dolorem eum +fugiat quo voluptas nulla pariatur?

+
+ + + diff --git a/sem_3/SiteWeb/tp2/cassoulet.css b/sem_3/SiteWeb/tp2/cassoulet.css new file mode 100644 index 0000000..1c9c1a6 --- /dev/null +++ b/sem_3/SiteWeb/tp2/cassoulet.css @@ -0,0 +1,35 @@ +body { + background-color: #d3d3d3; +} + +ul { + background-color: #f5deb4; +} + +img { + float:right; +} + +table { + background-color: #ffa301; + margin-left: 33%; +} + +table tr th { + background-color: #fffe00; +} + +table caption { + background-color: #ffa301; +} + +li a { + color: darkgreen; +} + +p.note { + background-color: yellow; + margin-left:60px; + margin-right:60px; + font-size:x-small; +} diff --git a/sem_3/SiteWeb/tp2/cassoulet.html b/sem_3/SiteWeb/tp2/cassoulet.html new file mode 100644 index 0000000..821b788 --- /dev/null +++ b/sem_3/SiteWeb/tp2/cassoulet.html @@ -0,0 +1,84 @@ + + + + + + + +

+ + + +

Cassoulet de Castelnaudary

+ +Pour 8 personnes - temps de cuisson 4h + + +
    +
  • 800 g de haricots lingots ou mieux, de haricots tarbais. +
  • 800 g d'échine de porc +
  • 8 tranches de poitrine de porc +
  • 200 g de couennes fraîches +
  • 1 saucisson à l'ail +
  • 2 cuillères de soupe de saindoux +
  • 2 jarrets de porc salés +
  • 250 g de tomates +
  • 3 oignons piqués de clous de girofle +
  • 200 g de carottes +
  • 1 bouquet garni +
  • poivre concassé +
+

+ +

+ +Dans grand pot faire revenir avec du saindoux les tomates et la +poitrine de porc coupées en dés ainsi que les carottes +émincées. Déposer les haricots sur le roux + (tous les éléments au-dessus) dans le même pot, couvrir avec deux + litres d'eau, ajouter le bouquet garni, + l'ail, les oignons, les couennes, les jarrets dessalés et la + viande. Laisser mijoter deux heures à feu doux. +

+ +

+Verser le tout dans une "cassole*", +ou un plat en terre creux et profond. Repartir la viande et adjoindre +le saucisson à l'ai coupé en tranches épaisses. +

+ +

+Poser le plat dans un four très doux. Quand il est recouverte d'une + croûte dorée, appuyer + avec une spatule pour qu'elle s'enfonce dans les haricots + (recommencer six fois pendant + tout le cuisson). Cuire au four pour au moins deux heures. Cette + longue et minutieuse + préparation est essentielle pour la réussite d'un excellent + cassoulet. +

+ +

+ *Une "cassole" est un pot en terre d' Issel dans laquelle on peut + mijoter et dorer. C'est l'origine du terme cassoulet. + +

+ +

+ + + + + + + + + + + + + +
+L'apport nutritionnel du cassoulet pour 100g
GlucidesLipidesProtides
45g30g25g
+ + diff --git a/sem_3/SiteWeb/tp2/cassoulet.jpg b/sem_3/SiteWeb/tp2/cassoulet.jpg new file mode 100644 index 0000000..f8a312d Binary files /dev/null and b/sem_3/SiteWeb/tp2/cassoulet.jpg differ diff --git a/sem_3/SiteWeb/tp2/index.html b/sem_3/SiteWeb/tp2/index.html new file mode 100644 index 0000000..3f1c656 --- /dev/null +++ b/sem_3/SiteWeb/tp2/index.html @@ -0,0 +1,65 @@ + + + + + Gaspard Coulet + + + +

TP2

+
+
+

Notes et réponses aux questions :

+ Par défaut, une div html occupe de l'espace en fonction de son contenu, en l'occurence, la largeur est de + 100% de la page, et la hauteur est relative au nombre de ligne.

+ + Par défaut il n'y a pas de marge! Le décallage visible est du au padding du conteneur parent : ici body + qui lui a un padding par defaut de 8px, d'ailleurs, la notion de "par défaut" est absurde car elle dépend + du navigateur utilisé.

+ + On remarque que la largeur d'une bordure s'additionne avec le padding de la division. +

+ En placant le texte contenu dans les div dans des balises p, on remarque qu'une marge se créée au dessus + et en dessous du texte, on peut même préciser que cette derniére fait 16 px. +

+ Concernant la durée de vie des support de stockage, il apparait que le support le plus fiable est + le stockage flash.

+ + Parmis la liste de format fourni, seul le .jpg est un format compressé. + + Parmis les formats d'archivage par defaut sur les sessions de la fac, les suivants permettent le verouillage : + .cbz; .ear; .war; .zip; + Ces 4 formats semblent permettre de protéger aussi la liste des fichiers. + + La division en multiples petits fichiers peut permettre une plus grande sécurité lors des transfert par le reseau + ( une instabilitée du reseau risquant de couper le transfert, il est preferable de le faire morceau par + morceau, pour ne pas avoir à tout recommencer. +

+ SAUVEGARDE + Sauvergarde incrementale : + "Méthode de backup se basant sur une sauvegarde complète, elle ne sert à sauvegarder que les fichiers modifiés depuis la dernière sauvegarde. Une sauvegarde incrémentielle copie donc uniquement les fichiers modifiés depuis la dernière sauvegarde complète ou incrémentielle et conserve les différentes versions d'un fichier. + Dès modification du ou des fichiers, l'attribut "archive" est positionné, devient "actif". C'est de cette façon que la sauvegarde incrémentale reconnait les fichiers modifiés pour les sauvegarder en réinitialisant du même coup cet attribut. + . Avantage : Comme une sauvegarde incrémentielle ne sauvegarde que les fichiers modifiés, elle constitue une protection rapide contre la perte de données. Elle nécessite également moins de ressources de stockage. + .Inconvénient : Chaque sauvegarde incrémentielle (entre deux sauvegardes complètes) doit être conservée car chacune d'elles se « construit » à partir de la précédente." + ( reference ) +

+ Synchronisation de supports : visiblement inexistant de google. +

+ Gestion de version ( on est en france, s'il vous plait) : + "Lorsque vous travaillez sur un projet de code, vous allez régulièrement y apporter des modifications, et par moments ces modifications vont provoquer des bugs. Lorsque vous revenez sur votre projet après quelques jours ou même quelques heures, il peut être difficile de vous souvenir des dernières modifications que vous avez effectuées et de retrouver vos repères dans votre code. + Avec un logiciel de versioning comme Git, vous pouvez garder la trace de toutes les modifications faites sur votre code pour pouvoir vous y retrouver à tout moment. À chaque fois que vous faites une série de modifications (créer un fichier, supprimer un fichier, modifier un texte dans un fichier, etc.), vous allez pouvoir enregistrer ces modifs dans un commit." + ( reference ) +

+ Logiciel de sauvegarde incrémentielle : ex : Bacula. + Logiciel de gestion de version : Git. +

+ Exemple de piratage d'information récent : ici +

+
+ + + diff --git a/sem_3/SiteWeb/tp2/photobase.png b/sem_3/SiteWeb/tp2/photobase.png new file mode 100644 index 0000000..6ff1cfa Binary files /dev/null and b/sem_3/SiteWeb/tp2/photobase.png differ diff --git a/sem_3/SiteWeb/tp3/index.html b/sem_3/SiteWeb/tp3/index.html new file mode 100644 index 0000000..219adb4 --- /dev/null +++ b/sem_3/SiteWeb/tp3/index.html @@ -0,0 +1,25 @@ + + + + + Gaspard Coulet + + + +

TP3

+
+
+

Notes et réponses aux questions :

+

La touche Inser permet de basculer entre les modes "Insert" et "Overwrite", en Insert, on intercalle un caractere entre deux autres, là ou le mode Overwrite réécrit par dessus un caractère existant.

+

Le retour à la ligne via la touche "enter" simple créée un nouveau paragraphe, tandis que la combinaison "shift+enter" se contente de revenir a la ligne.

+

Un espace insécable entre 2 mots s'assure que le logiciel considère ces deux mots comme un seul, qui ne peut être separé par un retour a la ligne, par exemple.

+

Pour ne pas avoir un "canichene", il faut cocher l'option "mots entiers uniquement"

+

"respecter la casse" signifie respecter le 'taille' ( majuscule, minuscule) des lettres

+

Ancrer une image comme caractère sert à l'intégrer dans le texte comme un caractère

+
+ + + diff --git a/sem_3/SiteWeb/tp3/texte.tar b/sem_3/SiteWeb/tp3/texte.tar new file mode 100644 index 0000000..93630e3 Binary files /dev/null and b/sem_3/SiteWeb/tp3/texte.tar differ diff --git a/sem_3/SiteWeb/tp4/calc.tar b/sem_3/SiteWeb/tp4/calc.tar new file mode 100644 index 0000000..82117dd Binary files /dev/null and b/sem_3/SiteWeb/tp4/calc.tar differ diff --git a/sem_3/SiteWeb/tp4/index.html b/sem_3/SiteWeb/tp4/index.html new file mode 100644 index 0000000..c5f1b8d --- /dev/null +++ b/sem_3/SiteWeb/tp4/index.html @@ -0,0 +1,17 @@ + + + + + Gaspard Coulet + + + +

TP4

+
+
+ + + diff --git a/sem_3/SiteWeb/tp5/exo1.odp b/sem_3/SiteWeb/tp5/exo1.odp new file mode 100644 index 0000000..daa852a Binary files /dev/null and b/sem_3/SiteWeb/tp5/exo1.odp differ diff --git a/sem_3/SiteWeb/tp5/index.html b/sem_3/SiteWeb/tp5/index.html new file mode 100644 index 0000000..6f22266 --- /dev/null +++ b/sem_3/SiteWeb/tp5/index.html @@ -0,0 +1,21 @@ + + + + + Gaspard Coulet + + + +

TP5

+
+

Lorsque l'image est inserée en tant que lien, elle n'est pas copiée, on accede directement a + l'image sur le disque, dans ces conditions si l'image vient a changer de nom, + ou qu'un des dossiers parents de l'image change de nom, le lien est rompu. +

+ + + diff --git a/sem_3/algo/TP3/FichiersTP3.tgz b/sem_3/algo/TP3/FichiersTP3.tgz new file mode 100644 index 0000000..2986ae0 Binary files /dev/null and b/sem_3/algo/TP3/FichiersTP3.tgz differ diff --git a/sem_3/algo/TP3/enonceTP3.pdf b/sem_3/algo/TP3/enonceTP3.pdf new file mode 100644 index 0000000..887d4cb Binary files /dev/null and b/sem_3/algo/TP3/enonceTP3.pdf differ diff --git a/sem_3/algo/TP3/fichierTP3.cpp b/sem_3/algo/TP3/fichierTP3.cpp new file mode 100644 index 0000000..1b804ed --- /dev/null +++ b/sem_3/algo/TP3/fichierTP3.cpp @@ -0,0 +1,127 @@ +#include +#include +#include +#include +#include +#include +#include "progListeSC.h" +#include "fichierTP3.h" +using namespace std; + + + +bool estTrieeLSC(ListeSC L){ + // Res : Renvoie true si L est une ListeSC tri�e, false sinon + + if (estVideLSC(L) || estVideLSC(L->succ)) + return true; + else + return (L->info < (L->succ)->info) && estTrieeLSC(L->succ); +} + +bool estListeIntervalle(ListeSC L){ + // Res : renvoie true si L est une Liste intervalle, renvoie false sinon + // A COMPLETER + while ( L->succ != NULL) { + if (L->succ->info - L->info != 1) return false; + L=L->succ; + } + return true; +} + +ListeSC consListeIntervalle1(int l, int p){ + // Donn�e : l>0 + // Res : renvoie une liste intervalle de longueur l et dont le premier �l�ment a pour valeur p + // Complexit� : Complexité dans le pire cas : O(N^2) ( boucle for + complexité de base de insererFinLC) + assert(l>0); + + int i; ListeSC L; + L=NULL; + for(i=0;i0 + // Res : renvoie une liste intervalle de longueur l et dont le premier �l�ment a pour valeur p + // Complexit� : O(N) + // Version iterative + p=p+l-1 ; //valeur du dernier element + ListeSC L = NULL; + while ( l>0) { + L=creerLSC(p, L); + p--; + l--; + } + return L; +} + +ListeSC consListeIntervalle3(int l, int p){ + // Donn�e : l>0 + // Res : renvoie une liste intervalle de longueur l et dont le premier �l�ment a pour valeur p + // Complexit� : O(N-1) + // Version r�cursive + ListeSC L=NULL; + if ( l == 0) return L; + else { + L = creerLSC(p,consListeIntervalle3(l-1,p+1)); + return L; + } +} + +void transfListeIntervalle(ListeSC L){ + // Donn�e : L est une liste tri�e non vide + // Res : modifie L en y inserant des �l�ments de sorte qu'elle soit une Liste Intervalle + // Complexit� : ???? + while ( L->succ != NULL) { + if (L->succ->info - L->info != 1) { + insererApresLSC(L,L,L->info+1); + } + L=L->succ; + } + return; +} + +ListeSC intersectionListesIntervalles(ListeSC l1, ListeSC l2){ + // Donn�e : l1 et l2 2 listes intervalles + // Res : Renvoie l'intersection de l1 et l2; les �l�ments de la liste r�sultat sont recopi�s + // Complexit� : ordre O(N) une premiere partie au moins inferieure a la somme + // de la longueur des listes, plus un appel lineaire a consListeIntervalle2 + assert(estListeIntervalle(l1)); + assert(estListeIntervalle(l2)); + while (l1 != NULL && l2 != NULL && l1->info != l2->info){ + if (l1->infoinfo){ + l1= l1->succ; + } + else { + l2=l2->succ; + } + } + int p= l1->info; + int l =0; + while ( l1 != NULL && l2 != NULL && l1->info == l2->info){ + l1=l1->succ; + l2=l2->succ; + l++; + } + return consListeIntervalle2(l,p); +} + +void plusLgSsLiInterv(ListeSC &L){ + // Donn�e : L liste + // Res : L est modifiee, elle est la plus longue sous-liste intervalle de la liste en entr�e + // Complexit� : ???? + // ListeSC ret = L; + // ListeSC ancien = NULL; + // int lenght = 0; + // while ( ret->succ != NULL){ + // if (ret->succ->info - ret->info != 1){ + // lenght=0; + // ret=ret->succ; + // } + // else { + // ancien + // } + // } +} diff --git a/sem_3/algo/TP3/fichierTP3.h b/sem_3/algo/TP3/fichierTP3.h new file mode 100644 index 0000000..17cf091 --- /dev/null +++ b/sem_3/algo/TP3/fichierTP3.h @@ -0,0 +1,43 @@ + +#ifndef FicTP3_H +#define FicTP3_H + + +bool estTrieeLSC(ListeSC L); + // Res : Renvoie true si L est une ListeSC triée, false sinon + +bool estListeIntervalle(ListeSC L); + // Res : renvoie true si L est une Liste intervalle, renvoie false sinon + +ListeSC consListeIntervalle1(int l, int p); + // Donnée : l>0 + // Res : renvoie une liste intervalle de longueur l et dont le premier élément a pour valeur p + +ListeSC consListeIntervalle2(int l, int p); + // Donnée : l>0 + // Res : renvoie une liste intervalle de longueur l et dont le premier élément a pour valeur p + +ListeSC consListeIntervalle3(int l, int p); + // Donnée : l>0 + // Res : renvoie une liste intervalle de longueur l et dont le premier élément a pour valeur p + + +void transfListeIntervalle(ListeSC L); + // Donnée : L est une liste triée non vide + // Res : modifie L en y inserant des éléments de sorte qu'elle soit une Liste Intervalle + +ListeSC intersectionListesIntervalles(ListeSC l1, ListeSC l2); + // Donnée : l1 et l2 2 listes intervalles + // Res : Renvoie l'intersection de l1 et l2; les éléments de la liste résultat sont recopiés + + +void plusLgSsLiInterv(ListeSC &L); + // Donnée : L liste + // Res : L est modifiee, elle est la lus longue sous-liste intervalle de la liste en entrée + + +#endif + + + + diff --git a/sem_3/algo/TP3/mainTP3.cpp b/sem_3/algo/TP3/mainTP3.cpp new file mode 100644 index 0000000..a0fb341 --- /dev/null +++ b/sem_3/algo/TP3/mainTP3.cpp @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include +#include +#include "progListeSC.h" +#include "fichierTP3.h" + +using namespace std; + + +int main(int argc, char *argv[]){ + ListeSC l1,l2,l3; + int q, lg, prem; + clock_t t1,t2,t3, t4; + + cout << "Numero de la question traitee (1/2/3/4/5/6) ? "; + cin >> q ; + switch (q){ + case 1 : + l1=lireLSC(); + if (estListeIntervalle(l1)) + cout << "Cette liste est une liste intervalle \n"; + else + cout << "Cette liste n'est pas une liste intervalle \n"; + break; + + case 2 : + cout << "Donnez 2 entiers strictement positifs (longueur et premier element de la liste intervalle) : "; + cin >> lg >> prem; + l1=consListeIntervalle1(lg,prem); + afficherLSC(l1); + l2=consListeIntervalle2(lg,prem); + afficherLSC(l2); + l3=consListeIntervalle3(lg,prem); + afficherLSC(l3); + break; + case 3 : + cout << "Donnez 2 entiers strictement positifs (longueur et premier element de la liste intervalle) : "; + cin >> lg >> prem; + t1=clock(); + l1=consListeIntervalle1(lg,prem); + t2=clock(); + l2=consListeIntervalle2(lg,prem); + t3=clock(); + l3=consListeIntervalle3(lg,prem); + t4=clock(); + + cout << " Construction d'une Liste de taille " << lg + << "\n version 1 " <<(double) (t2-t1)/CLOCKS_PER_SEC + << " sec\n version 2 " <<(double) (t3-t2)/CLOCKS_PER_SEC + << " sec\n version 3 "<<(double) (t4-t3)/CLOCKS_PER_SEC<< " sec\n"; + break; + case 4 : // Transformation d'une liste triee en liste Intervalle + cout << "Entrez une Liste Triee : "; + l1=lireLSC(); + transfListeIntervalle(l1); + cout << "Liste Intervalle construite "; + afficherLSC(l1); + break; + case 5 : // intersection de 2 listes intervalle + cout << "Liste intervalle : "; + l1=lireLSC(); + cout << "Liste intervalle : "; + l2=lireLSC(); + l3=intersectionListesIntervalles(l1,l2); + cout << "Intersection : \n"; + afficherLSC(l3); + break; + case 6 : + cout << "Entrez une Liste : "; + l1=lireLSC(); + plusLgSsLiInterv(l1); + cout << "Plus longue sousListe Intervalle : "; + afficherLSC(l1); + } + return 0; +} + + + + + diff --git a/sem_3/algo/TP3/progListeSC.cpp b/sem_3/algo/TP3/progListeSC.cpp new file mode 100644 index 0000000..40efb3e --- /dev/null +++ b/sem_3/algo/TP3/progListeSC.cpp @@ -0,0 +1,105 @@ +// progListeSC.c +#include +#include +#include +#include +#include +#include "progListeSC.h" + +using namespace std; + + +int estVideLSC(ListeSC l) +{ return (l==NULL);} + +ListeSC creerLSC(int val, ListeSC succ){ + ListeSC l = new CelluleSC; + l->info=val; + l->succ=succ; + return l;} + +void insererDebutLSC(ListeSC &p, int val){ + p=creerLSC(val,p); + return;} + +void insererApresLSC(ListeSC &l, ListeSC p, int val){ + assert((l)!=NULL); assert(p!=NULL); + (p->succ)=creerLSC(val,(p->succ)); + return;} + +void insererFinLSC(ListeSC &p, int val){ + if (p==NULL) + p=creerLSC(val,NULL); + else + insererFinLSC(p->succ,val); + return; +} + +ListeSC predecesseurLSC(ListeSC L, ListeSC P){ + assert(L!=NULL); + assert(P!=NULL); + + if (L->succ==P){return L;} + else {return predecesseurLSC(L->succ,P);} +} + +void supprimerLSC(ListeSC &L, ListeSC P){ + assert(L!=NULL); + assert(P!=NULL); + + if (L==P){L = L->succ;} + else { + predecesseurLSC(L,P)->succ = P->succ; + } + delete P; + return;} + +void supprimerDebutLSC(ListeSC &L){ + ListeSC P; + assert(L!=NULL); + + P=L; + L=L->succ; + delete P; + + return;} + + +void supprimerFinLSC(ListeSC &L){ + assert(L!=NULL); + + if (L->succ==NULL){ + delete L; + L=NULL;} + else { + ListeSC P=L,Q; + while ((P->succ)->succ!=NULL){ + P=P->succ;} + Q=P->succ; + P->succ=NULL; + delete Q;} + return;} + + + +void afficherLSC(ListeSC l){ + cout << "ListeSC : "; + while (! estVideLSC(l)){ + cout << l->info << " "; + l=l->succ;} + cout << endl; + return;} + +ListeSC lireLSC(){ + ListeSC l; + int i; + cout << "Entrez les éléments d'une liste d'entiers (0 pour finir)\n"; + l=NULL; + cin >> i; + while (i!=0) { + insererFinLSC(l,i); + cin >> i; + } + return l; +} + diff --git a/sem_3/algo/TP3/progListeSC.h b/sem_3/algo/TP3/progListeSC.h new file mode 100644 index 0000000..e35deed --- /dev/null +++ b/sem_3/algo/TP3/progListeSC.h @@ -0,0 +1,56 @@ + +//* ListeSC.h * +// Implantation du type Liste d'entiers Simplement Chainée + +#ifndef LISTESC_H +#define LISTESC_H + +typedef struct cellule { + int info; + struct cellule *succ;} CelluleSC; + +typedef CelluleSC *ListeSC; + + +// Res : renvoie 1 si L est la liste vide, renvoie 1 sinon +int estVideLSC(ListeSC L ); + +// Res : renvoie une ListeSC dont le premier élément est e et la suite de la liste L +ListeSC creerLSC(int e, ListeSC L); + +// Res : modifie la ListeSC L en y insérant en première place l'élément e +void insererDebutLSC(ListeSC &L, int e); + +// Donnée : L est une ListeSC non vide, P l'adresse d'un élément de L, e un entier +// Res : insère dans la liste L après l'élément d'adresse P 1 élément de valeur e +void insererApresLSC(ListeSC &L, ListeSC P, int e); + +// Res : modifie la listeSC L en y insérant en dernière place l'élément e +void insererFinLSC(ListeSC &L, int e); + +// Donnée : L est une ListeSC non Vide ; +// P est un pointeur non vide vers une cellule de la liste L +// L != P +// Res : renvoie l'adresse de la cellule précédant dans L celle pointée pas P +ListeSC predecesseurLSC(ListeSC L, ListeSC P); + +// Donnée : L est une ListeSC non Vide ; +// P est un pointeur non vide vers une cellule de la liste L +// Res : modifie L en supprimant de L la cellule pointée pas P +void supprimerLSC(ListeSC &L, ListeSC P); + +// Donnée : L est une ListeSC non Vide ; +// Res : modifie L en supprimant son dernier élément +void supprimerFinLSC(ListeSC &L); + +// Donnée : L est une ListeSC non Vide ; +// Res : modifie L en supprimant son premier élément +void supprimerDebutLSC(ListeSC &L); + +// Res : affiche la liste L +void afficherLSC(ListeSC L); + +// Res : renvoie la ListeSC des éléments saisis au clavier +ListeSC lireLSC(); + +#endif //LISTESC_H diff --git a/sem_3/algo/TP3/tp3 b/sem_3/algo/TP3/tp3 new file mode 100644 index 0000000..527995d Binary files /dev/null and b/sem_3/algo/TP3/tp3 differ diff --git a/sem_3/algo/TP4/fichierTP4.cpp b/sem_3/algo/TP4/fichierTP4.cpp new file mode 100644 index 0000000..9b90ad7 --- /dev/null +++ b/sem_3/algo/TP4/fichierTP4.cpp @@ -0,0 +1,194 @@ +#include +#include +#include +#include +//#include +#include +#include +#include "progListeSC.h" +using namespace std; + +typedef struct noeud { + int info; + struct noeud *sag; + struct noeud *sad;} NoeudSC; +typedef NoeudSC *ArbreBin; + +ArbreBin creerArbreBin(int e, ArbreBin G, ArbreBin D){ + /* Res : renvoie une ArbreBin dont la racine vaut e, le sag G et le sad D */ + ArbreBin A = new NoeudSC; + A->info=e; A->sag=G; A->sad=D; + return A;} + +void codageABdot(ofst ream& fichier, ArbreBin A){ + if (A != NULL){ + fichier << (long) A << " [label=\"" << A->info << "\" ] ;\n"; + if (A->sag != NULL) { + fichier << (long)A << " -> " << (long)(A->sag) << " [color=\"red\",label=\"g\" ] ;\n"; + codageABdot(fichier,A->sag);} + if (A->sad != NULL) { + fichier << (long)A << " -> " << (long)(A->sad) << " [color=\"blue\",label=\"d\" ] ;\n"; + codageABdot(fichier,A->sad);} + } + return;} + + +void dessinerAB(ArbreBin A, const char * nomFic, string titre){ + ofstream f(nomFic); + if (!f.is_open()){ + cout << "Impossible d'ouvrir le fichier en �criture !" << endl; + } + else { + f<< "digraph G { label = \""<< titre << "\" \n"; + codageABdot(f,A); + f << "\n }\n" ; + f.close();} + return;} + + +/* A COMPLETER */ +int sommeNoeuds(ArbreBin A){ + /* renvoie la somme des etiquettes des noeuds de l arbre binaire A */ + /* A COMPLETER */ + return A == NULL ? 0: A->info+sommeNoeuds(A->sag)+sommeNoeuds(A->sad); +} + +int profMinFeuille(ArbreBin A){ + /* renvoie la profondeur minimum des feuilles de l'arbre A ; A est non vide */ + assert(A!=NULL); + /* A COMPLETER */ + return A==NULL ? 0: A->info + ( profMinFeuille(A->sag)<= profMinFeuille(A->sad)) ? profMinFeuille(A->sag):profMinFeuille(A->sad)); +} + +ListeSC parcoursInfixe(ArbreBin A){ + /* renvoie la liste composee des etiquettes des noeuds de l'arbre A ordonn�e + selon l'ordre infixe */ + /* A COMPLETER */ + return A==NULL ? NULL: concatLSC(concatLSC(parcoursInfixe((A->sag), A->info),A->sad)); +} + +void effeuiller(ArbreBin& A){ + /* modifie l'arbre A en supprimant ses feuilles */ + /* A COMPLETER */ + return;} + +void tailler(ArbreBin& A, int p){ + /* modifie l'arbre A, en supprimant ses noeuds de profondeur au moins p ; p est un entier positif ou nul */ + /* A COMPLETER */ + return;} + +void tronconner(ArbreBin& A){ + /* modifie l'arbre A, en supprimant les noeuds dont un seul sous-arbre est vide */ + /* A COMPLETER */ + return;} + +ArbreBin genereAB(int n){ + /* A COMPLETER */ + return NULL;} + + +bool estParfait(ArbreBin A){ + // V�rifie si A est un arbre binaire parfait + return true; +} + +/*****************************************************************************/ +/* */ +/* main */ +/* */ +/*****************************************************************************/ +int main(int argc, char *argv[]){ + int q,i; + ArbreBin A,B,C; + ostringstream stre; + ListeSC L; + string chaine; + A=creerArbreBin(8, + creerArbreBin(7, + creerArbreBin(4,NULL,NULL), + creerArbreBin(9,NULL,NULL)), + creerArbreBin(3,NULL,NULL)); + + B=creerArbreBin(8, + creerArbreBin(2, + creerArbreBin(4,NULL,NULL), + creerArbreBin(9, + NULL, + creerArbreBin(1, + NULL, + creerArbreBin(7, + creerArbreBin(11,NULL,NULL), + creerArbreBin(5, + NULL, + NULL))))), + creerArbreBin(3, + creerArbreBin(12, + creerArbreBin(6,NULL,NULL), + NULL), + creerArbreBin(9,NULL,NULL))); + C=NULL; + C= creerArbreBin(1,C,C); + cout << "Numero de la question traitee (1/2/3/4/5/6/7) ? "; + cin >> q; + switch (q){ + case 1 : + dessinerAB(A,"arbre.dot","Arbre Bin"); + cout << "Somme des noeuds de l'arbre :"<< sommeNoeuds(A) << endl; + cout << "Profondeur minimum des feuilles de l'arbre : " << profMinFeuille(A) << endl; + system("dotty arbre.dot"); + break; + case 2 : + dessinerAB(A,"arbre.dot","Arbre Bin"); + L=parcoursInfixe(A); + cout << "Liste des noeuds de l'arbre en ordre infixe : "; + afficherLSC(L); + system("dotty arbre.dot"); + break; + case 3 : + dessinerAB(B,"arbre.dot","Arbre Bin"); + system("dotty arbre.dot&"); + effeuiller(B); + dessinerAB(B,"arbre2.dot","Arbre Bin effeuille"); + system("dotty arbre2.dot"); + break; + case 4 : + dessinerAB(B,"arbre.dot","Arbre Bin"); + system("dotty arbre.dot&"); + cout << " Donner une profondeur (entier positif) :"; + cin >> i; + tailler(B,i); + stre << i; + chaine = stre.str(); + chaine = "Arbre Bin taille a la profondeur " + chaine; + dessinerAB(B,"arbre2.dot",chaine); + system("dotty arbre2.dot&"); + break; + case 5 : + cout << " Donner un entier positif :"; + cin >> i; + stre << i; + chaine = "Arbre Bin " + stre.str(); + dessinerAB(genereAB(i),"arbre.dot", "Arbre Bin " + stre.str()); + system("dotty arbre.dot&"); + break; + case 6 : + dessinerAB(B,"arbre.dot","Arbre Bin"); + system("dotty arbre.dot&"); + tronconner(B); + dessinerAB(B,"arbre2.dot","Arbre tronconne"); + system("dotty arbre2.dot&"); + break; + case 7 : + A=genereAB(7); + chaine= estParfait(A) ? "Arbre parfait" : "Arbre non parfait"; + dessinerAB(A,"arbre.dot",chaine); + system("dotty arbre.dot"); + + B=genereAB(8); + chaine= estParfait(B) ? "Arbre parfait" : "Arbre non parfait"; + dessinerAB(B,"arbre2.dot",chaine); + system("dotty arbre2.dot&"); + break; + } + return 0; +} diff --git a/sem_3/algo/TP4/progListeSC.cpp b/sem_3/algo/TP4/progListeSC.cpp new file mode 100644 index 0000000..0a88c29 --- /dev/null +++ b/sem_3/algo/TP4/progListeSC.cpp @@ -0,0 +1,114 @@ +/**************************** progListeSC.c **********************************/ + +#include +#include +#include +#include +#include +#include "progListeSC.h" + +using namespace std; + + +bool estVideLSC(ListeSC l) +{ return (l==NULL);} + +ListeSC creerLSC(int val, ListeSC succ){ + ListeSC l = new CelluleSC; + l->info=val; + l->succ=succ; + return l;} + +void insererDebutLSC(ListeSC& p, int val){ + p=creerLSC(val,p); +} + +void insererApresLSC(ListeSC& l, ListeSC p, int val){ + assert((l)!=NULL); assert(p!=NULL); + (p->succ)=creerLSC(val,(p->succ)); +} + +void insererFinLSC(ListeSC& p, int val){ + if ((p)==NULL) + p=creerLSC(val,NULL); + else + insererFinLSC(p->succ,val); +} + +ListeSC predecesseurLSC(ListeSC L, ListeSC P){ + assert(L!=NULL); + assert(P!=NULL); + + if (L->succ==P){return L;} + else {return predecesseurLSC(L->succ,P);} +} + +void supprimerLSC(ListeSC& L, ListeSC P){ + assert(L!=NULL); + assert(P!=NULL); + + if (L==P){L=L->succ;} + else { + predecesseurLSC(L,P)->succ=P->succ; + } + delete(P); +} + +void supprimerDebutLSC(ListeSC& L){ + ListeSC P; + + assert(L!=NULL); + + + P=L; + L=L->succ; + delete(P); +} + + +void supprimerFinLSC(ListeSC& L){ + assert(L!=NULL); + + if (L->succ==NULL){ + delete(L); + L=NULL;} + else { + ListeSC P=L,Q; + while ((P->succ)->succ!=NULL){ + P=P->succ;} + Q=P->succ; + P->succ=NULL; + delete(Q);} +} + + + +void afficherLSC(ListeSC l){ + cout<< "ListeSC : "; + while (! estVideLSC(l)){ + cout << " " << l->info <<" "; + l=l->succ;} + cout << endl; +} + +ListeSC lireLSC(){ + ListeSC l; + int i; + cout << "Entrez les éléments d'une liste d'entiers (0 pour finir)\n"; + l=NULL; + cin >> i; + while (i!=0) { + insererFinLSC(l,i); + cin >>i ; + } + return l; +} + +ListeSC concatLSC(ListeSC L1, ListeSC L2){ + ListeSC P; + if (L1==NULL) return L2; + else { + P= L1; + while (P->succ != NULL) P=P->succ; + P->succ = L2; + return L1;}} diff --git a/sem_3/algo/TP4/progListeSC.h b/sem_3/algo/TP4/progListeSC.h new file mode 100644 index 0000000..f60d8f4 --- /dev/null +++ b/sem_3/algo/TP4/progListeSC.h @@ -0,0 +1,59 @@ + +/**************************** ListeSC.h **************************************/ +/* Implantation du type Liste d'entiers Simplement Chainée */ + +#ifndef LISTESC_H +#define LISTESC_H + +typedef struct cellule { + int info; + struct cellule *succ;} CelluleSC; + +typedef CelluleSC *ListeSC; + + +bool estVideLSC(ListeSC L ); +/* Res : renvoie 1 si L est la liste vide, renvoie 1 sinon */ + +ListeSC creerLSC(int e, ListeSC L); +/* Res : renvoie une ListeSC dont le premier élément est e et la suite de la liste L */ + +void insererDebutLSC(ListeSC & L, int e); +/* Res : modifie la ListeSC L en y insérant en premiere place l'élément e */ + +void insererApresLSC(ListeSC & L, ListeSC P, int e); +/* Donnée : L est une ListeSC non vide, P l'adresse d'un élément de L, e un entier */ +/* Res : insère dans la liste L après l'élément d'adresse P 1 élément de valeur e */ + +void insererFinLSC(ListeSC & L, int e); +/* Res : modifie la listeSC L en y insérant en dernière place l'élément e */ + +ListeSC predecesseurLSC(ListeSC L, ListeSC P); +/* Donnée : L est une ListeSC non Vide ; */ +/* P est un pointeur non vide vers une cellule de la liste L */ +/* L != P */ +/* Res : renvoie l'adresse de la cellule précédant dans L celle pointée pas P */ + +void supprimerLSC(ListeSC & L, ListeSC P); +/* Donnée : L est une ListeSC non Vide ; */ +/* P est un pointeur non vide vers une cellule de la liste L */ +/* Res : modifie L en supprimant de L la cellule pointée pas P */ + +void supprimerFinLSC(ListeSC & L); +/* Donnée : L est une ListeSC non Vide ; */ +/* Res : modifie L en supprimant son dernier élément */ + +void supprimerDebutLSC(ListeSC & L); +/* Donnée : L est une ListeSC non Vide ; */ +/* Res : modifie L en supprimant son premier élément */ + +void afficherLSC(ListeSC L); +/* Res : affiche la liste L */ + +ListeSC lireLSC(); +/* Res : renvoie la ListeSC des éléments saisis au clavier */ + +ListeSC concatLSC(ListeSC L1, ListeSC L2); +/* Res : renvoie la ListeSC, concaténation des listes L1 et L2, en modifiant le chaînage de L1*/ + +#endif /*LISTESC_H*/ diff --git a/sem_3/algo/TP4/tpIN301_4.pdf b/sem_3/algo/TP4/tpIN301_4.pdf new file mode 100644 index 0000000..fde8e51 Binary files /dev/null and b/sem_3/algo/TP4/tpIN301_4.pdf differ diff --git a/sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp b/sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp new file mode 100644 index 0000000..18d30ab --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +#include +#include "outilsTab.h" + +using namespace std; + + +int main(int argc, char ** argv) +{ + int* Tab; + struct triplet res; + int sm, taille, q; + clock_t t1, t2; + + srand(time(NULL)); + printf("Numero de la question traitee (1/2/3/4) ? "); + scanf("%d",&q); + switch (q){ + case 1 : + taille=1000; + Tab=genTab(taille); + t1=clock(); sm=ssTabSomMax1(Tab,taille); t2=clock(); + cout << "\n Somme Max1 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + t1=clock(); sm=ssTabSomMax2(Tab,taille); t2=clock(); + cout << "\n Somme Max2 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + t1=clock(); sm=ssTabSomMax3(Tab,taille); t2=clock(); + cout << "\n Somme Max3 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + t1=clock(); sm=ssTabSomMax4(Tab,taille); t2=clock(); + cout << "\n Somme Max4 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + + break; + case 2 : + fichierTemps("sm1.dat", 1000, 100, ssTabSomMax1); + fichierTemps("sm2.dat", 1000, 100, ssTabSomMax2); + fichierTemps("sm3.dat", 1000, 100, ssTabSomMax3); + fichierTemps("sm4.dat", 1000, 100, ssTabSomMax4); + system("gnuplot trace1.gnu"); + fichierTemps("sm2.dat", 20000, 1000, ssTabSomMax2); + fichierTemps("sm3.dat", 20000, 1000, ssTabSomMax3); + fichierTemps("sm4.dat", 20000, 1000, ssTabSomMax4); + system("gnuplot trace2.gnu"); + fichierTemps("sm3.dat", 1000000, 100000, ssTabSomMax3); + fichierTemps("sm4.dat", 10000000, 1000000, ssTabSomMax4); + system("gnuplot trace3.gnu"); + break; + case 3 : + Tab=genTab(20); + afficheTab(Tab,20); + res=indSsTabSomMax(Tab,20); + cout << "\n somme Max : " << res.somMax << "\n debut souTab : " << res.deb << "\n fin SouTab : " << res.fin << endl; + break; + case 4 : + Tab=genTab(20); + afficheTab(Tab,20); + rangerElemNeg(Tab,20); + afficheTab(Tab,20); + break; + } + return 0; +} + diff --git a/sem_3/algo/tp1-done/PROG_TP1/outilsTab.cpp b/sem_3/algo/tp1-done/PROG_TP1/outilsTab.cpp new file mode 100644 index 0000000..6643b13 --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/outilsTab.cpp @@ -0,0 +1,131 @@ +#include +#include + +#include // pour rand +#include +#include "outilsTab.h" +using namespace std; + +int* genTab(int n){ + int* t; int i; + t=new int[n]; + for (i=0;i somMax) somMax = som; + } + } + return somMax; +} + +int ssTabSomMax2(int* T, int taille){ + int somMax, som, i, j; + somMax=0; + for (i=0;i somMax) somMax = som; + } + } + return somMax; +} + +int sTSM3(int* T,int g,int d){ + int m, som, i, smgd, smdg, smm, smg, smd; + assert(g<=d); + if (g==d){ + if (T[g]>0) return T[g]; else return 0; + } + else { + m = (d+g)/2; + smg=sTSM3(T,g,m); + smd=sTSM3(T,m+1,d); + smgd=0; som=0; + for (i=m;i>=g;i--){ + som=som+T[i]; + if (som > smgd) smgd=som; + } + smdg=0; som=0; + for(i=m+1;i<=d;i++){ + som=som+T[i]; + if (som>smdg) smdg=som; + } + smm=smgd+smdg; + if ((smg>=smd) && (smg>=smm)) return smg; + else { + if (smd>=smm) return smd; + else return smm; + } + } +} + +int ssTabSomMax3(int* T, int taille){ + return sTSM3(T,0,taille-1); +} + +int ssTabSomMax4(int* T, int taille){ + int ancienplusgrand = 0; + int somme =0; + for (int i =0; i < taille; i ++) { + somme+=T[i]; + if (somme < 0 ){ + somme= 0; + } + ancienplusgrand= ancienplusgrand> somme ? ancienplusgrand : somme; + } + return ancienplusgrand; +} + +struct triplet indSsTabSomMax(int* T, int taille){ +/* A COMPLETER */ + struct triplet res; + res.somMax=0; res.deb=0; res.fin=0; + return res; +} + + +void rangerElemNeg(int* T,int taille){ +/* A COMPLETER */ + return; + +} diff --git a/sem_3/algo/tp1-done/PROG_TP1/outilsTab.h b/sem_3/algo/tp1-done/PROG_TP1/outilsTab.h new file mode 100644 index 0000000..9576c28 --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/outilsTab.h @@ -0,0 +1,74 @@ +#ifndef OUTILSTAB_H_INCLUDED +#define OUTILSTAB_H_INCLUDED + +struct triplet { + int deb, fin, somMax;} ; + +int* genTab(int t); +// Renvoie un tableau de taille t, dont les éléments sont des entiers aléatoires compris entre -100 et 100 + + +void afficheTab(int* T, int t); +// Affiche les éléments de T, tableau d'entiers de taille t + + +void fichierTemps(const char* nomFic, int tMaxTab, int pasTaille, int (*fssTabSomMax)(int*, int)); +// Données nomFic une chaîne de caractères, tMaxTab et pasTaille 2 entiers positifs pasTaille < tMaxTab +// fssTabSomMax nom d'une fonction dont les données sont 1 tableau d'entiers et la taille de ce tableau et renvoyant 1 entier +// Resultat : crée un fichier de nom nomfic et pour chaque taille comprise entre pasTaille et tMaxTab (avec un pas de pasTaille), +// génère un tableau de cette taille +// execute la fonction ssTabSomMax sur ce tableau +// ajoute au fichier de nom nomfic la taille du tableau et le temps d'execution de ssTabSomMax + + +int ssTabSomMax1(int* Tab, int n); +/* + Données : Tab un tableau d'entiers de taille n + Resultat : renvoie la somme max des sous-tableaux de tab, algo de complexite O(n^3) +*/ + +int ssTabSomMax2(int*, int); + +/* + Données : Tab un tableau d'entiers de taille n + Resultat : renvoie la somme max des sous-tableaux de tab, algo de complexite O(n^2) +*/ + +int ssTabSomMax3(int* Tab, int n); +/* + Données : Tab un tableau d'entiers de taille n + Resultat : renvoie la somme max des sous-tableaux de tab, algo de complexite O(n log n) +*/ + +int ssTabSomMax4(int* Tab, int n); +/* + Données : Tab un tableau d'entiers de taille n + Resultat : renvoie la somme max des sous-tableaux de tab, algo de complexite O(n) + FONCTION A COMPLETER +*/ + +struct triplet indSsTabSomMax(int* Tab,int n); +/* + Données : Tab un tableau d'entiers de taille n + Resultat : renvoie une structure contenant + la somme max des sous-tableaux de tab, + l'indice de début d'un sous-tableau de somme max + l'indice de fin d'un sous-tableau de somme max + algo de complexite O(n) + FONCTION A COMPLETER + +*/ + + +void rangerElemNeg(int* Tab,int n); +/* + Données : Tab un tableau d'entiers de taille n + Resultat : modifie le tableau Tab de sorte que tous les éléments négatifs soient placés avant tous les éléments positifs + algo de complexite O(n) + FONCTION A COMPLETER + +*/ + + + +#endif /* OUTILSTAB_H_INCLUDED */ diff --git a/sem_3/algo/tp1-done/PROG_TP1/sm1.dat b/sem_3/algo/tp1-done/PROG_TP1/sm1.dat new file mode 100644 index 0000000..6fe54af --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/sm1.dat @@ -0,0 +1,10 @@ +100 0 +200 0 +300 0.03125 +400 0.03125 +500 0.046875 +600 0.09375 +700 0.15625 +800 0.21875 +900 0.3125 +1000 0.4375 diff --git a/sem_3/algo/tp1-done/PROG_TP1/sm2.dat b/sem_3/algo/tp1-done/PROG_TP1/sm2.dat new file mode 100644 index 0000000..79cda5f --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/sm2.dat @@ -0,0 +1,7 @@ +1000 0 +2000 0 +3000 0.015625 +4000 0.015625 +5000 0.03125 +6000 0.046875 +7000 0.0625 diff --git a/sem_3/algo/tp1-done/PROG_TP1/sm3.dat b/sem_3/algo/tp1-done/PROG_TP1/sm3.dat new file mode 100644 index 0000000..811f1f9 --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/sm3.dat @@ -0,0 +1,10 @@ +100 0 +200 0 +300 0 +400 0 +500 0 +600 0 +700 0 +800 0 +900 0 +1000 0 diff --git a/sem_3/algo/tp1-done/PROG_TP1/sm4.dat b/sem_3/algo/tp1-done/PROG_TP1/sm4.dat new file mode 100644 index 0000000..811f1f9 --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/sm4.dat @@ -0,0 +1,10 @@ +100 0 +200 0 +300 0 +400 0 +500 0 +600 0 +700 0 +800 0 +900 0 +1000 0 diff --git a/sem_3/algo/tp1-done/PROG_TP1/tp1 b/sem_3/algo/tp1-done/PROG_TP1/tp1 new file mode 100644 index 0000000..8cce618 Binary files /dev/null and b/sem_3/algo/tp1-done/PROG_TP1/tp1 differ diff --git a/sem_3/algo/tp1-done/PROG_TP1/trace1.gnu b/sem_3/algo/tp1-done/PROG_TP1/trace1.gnu new file mode 100644 index 0000000..a7f446a --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/trace1.gnu @@ -0,0 +1,5 @@ +set ylabel "secondes" +plot "sm4.dat" with lines, "sm3.dat" with lines, "sm2.dat" with lines, "sm1.dat" with lines +pause -1 "Appuyez sur RETURN pour continuer" +exit + diff --git a/sem_3/algo/tp1-done/PROG_TP1/trace2.gnu b/sem_3/algo/tp1-done/PROG_TP1/trace2.gnu new file mode 100644 index 0000000..ba4de89 --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/trace2.gnu @@ -0,0 +1,5 @@ +set ylabel "secondes" +plot "sm4.dat" with lines, "sm3.dat" with lines, "sm2.dat" with lines +pause -1 "Appuyez sur RETURN pour continuer" +exit + diff --git a/sem_3/algo/tp1-done/PROG_TP1/trace3.gnu b/sem_3/algo/tp1-done/PROG_TP1/trace3.gnu new file mode 100644 index 0000000..1907656 --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/trace3.gnu @@ -0,0 +1,5 @@ +set ylabel "secondes" +plot "sm4.dat" with lines, "sm3.dat" with lines +pause -1 "Appuyez sur RETURN pour continuer" +exit + diff --git "a/sem_3/algo/tp1-done/\303\251nonc\303\251TP1.pdf" "b/sem_3/algo/tp1-done/\303\251nonc\303\251TP1.pdf" new file mode 100644 index 0000000..bdd788a Binary files /dev/null and "b/sem_3/algo/tp1-done/\303\251nonc\303\251TP1.pdf" differ diff --git a/sem_3/algo/tp2/fichierTP2.cpp b/sem_3/algo/tp2/fichierTP2.cpp new file mode 100644 index 0000000..3a73196 --- /dev/null +++ b/sem_3/algo/tp2/fichierTP2.cpp @@ -0,0 +1,214 @@ +#include +#include +#include +#include +#include +#include +#include "progListeSC.h" +using namespace std; + +// DERNIERLSC ET ESTTRIEELSC +// Res : Renvoie l'adresse de la derniere cellule de la liste non vide L +ListeSC dernierLSC(ListeSC L){ + while ( L->succ != NULL){ + L=L->succ; + } + return L; +} + +// Res : Renvoie 1 si L est une ListeSC triee, 0 sinon +int estTrieeLSC(ListeSC L){ + while(L->succ != NULL){ + if (L->info > L->succ->info) { + return 0; + } + L=L->succ; + } + return 1; +} + + +// OTERREPETITION +// Res : Supprime de la ListeSC L tous les elements consecutifs egaux +// Opere en modifiant le chainage de la ListeSC L +// version iterative +void oterRepetitionLSC(ListeSC L){ + if (L->succ==NULL || L== NULL) return; + while ( L->succ != NULL){ + if (L->info == L->succ->info ) { + ListeSC tmp= L->succ; + L->succ=L->succ->succ; + delete tmp; + } + if ( L->succ != NULL ) L=L->succ; + } +} + +// Res : Supprime de la ListeSC L tous les elements consecutifs egaux +// Opere en modifiant le chainage de la ListeSC L +// version recursive +void oterRepetitionLSCR(ListeSC L){ + if ( L -> succ == NULL || L== NULL) return; + if ( L->succ->info==L->info){ + ListeSC tmp = L; + L->succ=L->succ->succ; + delete tmp; + } + oterRepetitionLSC(L->succ); + return; +} + + +// CONCATENATION DE 2 LISTES +// Res : Modifie la liste L1 en la concatenant avec la liste l2 +// Opere en modifiant le chainage de la listeSC L1 +// Version utilisant la fonction dernierLSC +void concatLSC(ListeSC L1,ListeSC L2){ + ListeSC tmp = dernierLSC(L1); + tmp->succ = L2; + return; +} + +// Res : Renvoie la ListeSC obtenue par concatenation des ListeSC L1 et L2 +// Opere en recopiant les elements des 2 listeSC L1 et L2 +// complexite : ??? +ListeSC concatLSCCopie(ListeSC L1,ListeSC L2){ + ListeSC L3=NULL; + while ( L1 != NULL) { + insererFinLSC(L3, L1->info); + L1 = L1->succ; + } + while (L2 != NULL){ + insererFinLSC(L3,L2->info); + L2=L2->succ; + } + return L3; +} + + +int main(int argc, char *argv[]){ + ListeSC l1,l2,l3; + int q; + + cout << "Numero de la question traitee (1/2/3/4/5) ? "; + cin >> q; + switch (q){ + case 1 : // Test des operations de base sur les listes + l1 = lireLSC(); + + // insertion d'un element de valeur 11 en derniere position de la liste l1 + // en utilisant insererFinLSC + // Completez + insererFinLSC(l1, 11); + + + cout << "Insertion de 11 en derniere position "; afficherLSC(l1); + + // insertion d'un element de valeur 22 en 2eme position de la liste l1 + // en utilisant insererApresLSC + // Completez + insererApresLSC(l1, l1,22); + + + cout << "Insertion de 22 en 2eme position ";afficherLSC(l1); + + // insertion d'un element de valeur 33 en 2eme position de la liste l1 + // sans utiliser insererApresLSC + // Completez + l1=creerLSC(l1->info, creerLSC(33, l1->succ)); + + + cout << "Insertion de 33 en 2eme position ";afficherLSC(l1); + + // Suppression du 2eme element de la liste en utilisant supprimerLSC + // Completez + supprimerLSC(l1, l1->succ); + + + cout << "Suppression du 2eme element "; afficherLSC(l1); + + // Suppression du 2eme element de la liste sans utiliser supprimerLSC + // Completez + if ( l1->succ!=NULL){ + ListeSC templist = l1->succ; + l1->succ = l1->succ->succ; + delete templist; + } + + cout << "Suppression du 2eme element "; afficherLSC(l1); + + // Inversion des valeurs des 2 premiers elements + // en modifiant les champs info (sans modifier le chainage) + // Completez + if (l1->succ != NULL){ + int tmp = l1->succ->info; + l1->succ->info=l1->info; + l1->info= tmp; + } + + + cout << "Inversion des valeurs des 2 premiers elements " ; afficherLSC(l1); + + // Inversion des 2 premiers elements + // en modifiant les champs succ (le chainage) + // Completez + if ( l1->succ != NULL) { + ListeSC templist; + templist = l1; + l1 = l1->succ; + templist->succ = l1->succ; + l1->succ= templist; + } + + + cout << "Inversion des 2 premiers elements "; afficherLSC(l1); + break; + + case 2 : // Test des fonctions estTrieeLSC et dernierLSC + l1 = lireLSC(); + if (estTrieeLSC(l1)) cout << "Cette liste est triee\n"; + else cout << "Cette liste n'est pas triee\n"; + if (l1 != NULL) + cout << "La valeur de son dernier element est " << dernierLSC(l1)->info << endl; + break; + + case 3: // Test des fonctions oterRepetitionLSC + l1 = lireLSC(); + oterRepetitionLSC(l1); + cout << "Liste sans repetition (version iterative) :\n"; + afficherLSC(l1); + l1 = lireLSC(); + oterRepetitionLSCR(l1); + cout << "Liste sans repetition (version recursive) :\n"; + afficherLSC(l1); + break; + + case 4 : // Test de la premiere fonction de concatenation de listes + l1 = lireLSC(); + l2 = lireLSC(); + concatLSC(l1,l2); + cout << "Concatenation des 2 listes (en modifiant le chainage) :\n"; afficherLSC(l1); + if ((l1 != NULL) && (l2 != NULL) ) + cout << "Adresse derniere cellule de l1 : " << (void *) dernierLSC(l1) << ", de l2 : "<< (void *) dernierLSC(l2) << endl; + cout << " Ajout de 44 en fin de la liste l1\n"; + insererFinLSC(l1,44); + cout << "Nouvelle valeur de l1:"; afficherLSC(l1); cout << endl; + cout << "Nouvelle valeur de l2: "; afficherLSC(l2); cout << endl; + break; + + case 5 : // Test des fonctions de concatenation de listes + l1 = lireLSC(); + l2 = lireLSC(); + l3 = concatLSCCopie(l1,l2); + cout << "Concatenation des 2 listes (par recopie des listes) : "; afficherLSC(l3); cout << endl; + if ((l1 != NULL) && (l2 != NULL) ) + cout << "Adresse derniere cellule de l1 : " << (void *) dernierLSC(l1) << " , de l2 : " << (void *) dernierLSC(l2) << ", de l3 : " << (void *) dernierLSC(l3) << endl; + cout << " Ajout de 55 en fin de la liste l1\n"; + insererFinLSC(l1,55); + cout << "Nouvelle valeur de l1: "; afficherLSC(l1); cout << endl; + cout << "Nouvelle valeur de l2: "; afficherLSC(l2); cout << endl; + cout << "Nouvelle valeur de l3: "; afficherLSC(l3); cout << endl; + break; + } + return 0; +} diff --git a/sem_3/algo/tp2/prog b/sem_3/algo/tp2/prog new file mode 100644 index 0000000..f4f6684 Binary files /dev/null and b/sem_3/algo/tp2/prog differ diff --git a/sem_3/algo/tp2/progListeSC.cpp b/sem_3/algo/tp2/progListeSC.cpp new file mode 100644 index 0000000..dd81a27 --- /dev/null +++ b/sem_3/algo/tp2/progListeSC.cpp @@ -0,0 +1,104 @@ +// progListeSC.c +#include +#include +#include +#include +#include +#include "progListeSC.h" + +using namespace std; + + +int estVideLSC(ListeSC l) +{ return (l==NULL);} + +ListeSC creerLSC(int val, ListeSC succ){ + ListeSC l = new CelluleSC; + l->info=val; + l->succ=succ; + return l;} + +void insererDebutLSC(ListeSC &p, int val){ + p=creerLSC(val,p); + return;} + +void insererApresLSC(ListeSC &l, ListeSC p, int val){ + assert((l)!=NULL); assert(p!=NULL); + (p->succ)=creerLSC(val,(p->succ)); + return;} + +void insererFinLSC(ListeSC &p, int val){ + if (p==NULL) + p=creerLSC(val,NULL); + else + insererFinLSC(p->succ,val); + return; +} + +ListeSC predecesseurLSC(ListeSC L, ListeSC P){ + assert(L!=NULL); + assert(P!=NULL); + + if (L->succ==P){return L;} + else {return predecesseurLSC(L->succ,P);} +} + +void supprimerLSC(ListeSC &L, ListeSC P){ + assert(L!=NULL); + assert(P!=NULL); + + if (L==P){L = L->succ;} + else { + predecesseurLSC(L,P)->succ = P->succ; + } + delete P; + return;} + +void supprimerDebutLSC(ListeSC &L){ + ListeSC P; + assert(L!=NULL); + + P=L; + L=L->succ; + delete P; + + return;} + + +void supprimerFinLSC(ListeSC &L){ + assert(L!=NULL); + + if (L->succ==NULL){ + delete L; + L=NULL;} + else { + ListeSC P=L,Q; + while ((P->succ)->succ!=NULL){ + P=P->succ;} + Q=P->succ; + P->succ=NULL; + delete Q;} + return;} + + + +void afficherLSC(ListeSC l){ + cout << "ListeSC : "; + while (! estVideLSC(l)){ + cout << l->info << " "; + l=l->succ;} + cout << endl; + return;} + +ListeSC lireLSC(){ + ListeSC l; + int i; + cout << "Entrez les éléments d'une liste d'entiers (0 pour finir)\n"; + l=NULL; + cin >> i; + while (i!=0) { + insererFinLSC(l,i); + cin >> i; + } + return l; +} diff --git a/sem_3/algo/tp2/progListeSC.h b/sem_3/algo/tp2/progListeSC.h new file mode 100644 index 0000000..c259352 --- /dev/null +++ b/sem_3/algo/tp2/progListeSC.h @@ -0,0 +1,56 @@ + +//* ListeSC.h * +// Implantation du type Liste d'entiers Simplement Chainée + +#ifndef LISTESC_H +#define LISTESC_H + +typedef struct cellule { + int info; + struct cellule *succ;} CelluleSC; + +typedef CelluleSC *ListeSC; + + +// Res : renvoie 1 si L est la liste vide, renvoie 1 sinon +int estVideLSC(ListeSC L ); + +// Res : renvoie une ListeSC dont le premier élément est e et la suite de la liste L +ListeSC creerLSC(int e, ListeSC L); + +// Res : modifie la ListeSC L en y insérant en première place l'élément e +void insererDebutLSC(ListeSC &L, int e); + +// Donnée : L est une ListeSC non vide, P l'adresse d'un élément de L, e un entier +// Res : insère dans la liste L après l'élément d'adresse P 1 élément de valeur e +void insererApresLSC(ListeSC &L, ListeSC P, int e); + +// Res : modifie la listeSC L en y insérant en dernière place l'élément e +void insererFinLSC(ListeSC &L, int e); + +// Donnée : L est une ListeSC non Vide ; +// P est un pointeur non vide vers une cellule de la liste L +// L != P +// Res : renvoie l'adresse de la cellule précédant dans L celle pointée pas P +ListeSC predecesseurLSC(ListeSC L, ListeSC P); + +// Donnée : L est une ListeSC non Vide ; +// P est un pointeur non vide vers une cellule de la liste L +// Res : modifie L en supprimant de L la cellule pointée pas P +void supprimerLSC(ListeSC &L, ListeSC P); + +// Donnée : L est une ListeSC non Vide ; +// Res : modifie L en supprimant son dernier élément +void supprimerFinLSC(ListeSC &L); + +// Donnée : L est une ListeSC non Vide ; +// Res : modifie L en supprimant son premier élément +void supprimerDebutLSC(ListeSC &L); + +// Res : affiche la liste L +void afficherLSC(ListeSC L); + +// Res : renvoie la ListeSC des éléments saisis au clavier +ListeSC lireLSC(); + +#endif //LISTESC_H diff --git "a/sem_3/algo/tp2/\303\251nonc\303\251 TP2.pdf" "b/sem_3/algo/tp2/\303\251nonc\303\251 TP2.pdf" new file mode 100644 index 0000000..9d961dc Binary files /dev/null and "b/sem_3/algo/tp2/\303\251nonc\303\251 TP2.pdf" differ diff --git a/sem_3/project/Documents du Projet-20171011/SujetBatailleNavale.pdf b/sem_3/project/Documents du Projet-20171011/SujetBatailleNavale.pdf new file mode 100644 index 0000000..bdcfa0a Binary files /dev/null and b/sem_3/project/Documents du Projet-20171011/SujetBatailleNavale.pdf differ diff --git a/sem_3/project/Documents du Projet-20171011/test-piece.cpp b/sem_3/project/Documents du Projet-20171011/test-piece.cpp new file mode 100644 index 0000000..fcbff74 --- /dev/null +++ b/sem_3/project/Documents du Projet-20171011/test-piece.cpp @@ -0,0 +1,65 @@ +#include "window.h" + + +void myprogram(){ + int ch; + int h=10,w=10; + Window menu(3,30,1,0); + Window plateau(h,w,1,6); + menu.setCouleurBordure(BRED); + plateau.setCouleurBordure(BBLUE); + + menu.print(1,1,"Tapez q pour quitter !!!",WRED); + + int x=w/2,y=h/2; + char p='X'; + Color col=WBLUE; + plateau.print(x,y,p,col); + + while((ch = getch()) != 'q') + { + switch (ch) { + case '1': + col=BMAGENTA; + break; + case '2': + col=WCYAN; + break; + case 'c': + plateau.clear(); + break; + case KEY_UP: + plateau.print(x,y,' '); + plateau.print(x,--y,p,col); + break; + case KEY_DOWN: + plateau.print(x,y,' '); + plateau.print(x,++y,p,col); + break; + case KEY_LEFT: + plateau.print(x,y,' '); + plateau.print(--x,y,p,col); + break; + case KEY_RIGHT: + plateau.print(x,y,' '); + plateau.print(++x,y,p,col); + break; + case '\n': + x=w/2,y=h/2; + plateau.print(x,y,p,col); + break; + case '\t': + Color tmp= menu.getCouleurBordure(); + menu.setCouleurBordure(plateau.getCouleurBordure()); + plateau.setCouleurBordure(tmp); + break; + } + } +} + +int main(){ + startProgramX(); + myprogram(); + stopProgramX(); + return 0; +} diff --git a/sem_3/project/Documents du Projet-20171011/window.cpp b/sem_3/project/Documents du Projet-20171011/window.cpp new file mode 100644 index 0000000..65694a7 --- /dev/null +++ b/sem_3/project/Documents du Projet-20171011/window.cpp @@ -0,0 +1,114 @@ +#include "window.h" + + +void init_colors(void) +{ + start_color(); + init_pair(WBLACK, COLOR_WHITE, COLOR_BLACK); + init_pair(WCYAN, COLOR_WHITE, COLOR_CYAN); + init_pair(WBLUE, COLOR_WHITE, COLOR_BLUE); + init_pair(WYELLOW, COLOR_WHITE, COLOR_YELLOW); + init_pair(WGREEN, COLOR_WHITE, COLOR_GREEN); + init_pair(WMAGENTA, COLOR_WHITE, COLOR_MAGENTA); + init_pair(WRED, COLOR_WHITE, COLOR_RED); + init_pair(BWHITE, COLOR_BLACK, COLOR_WHITE); + init_pair(BCYAN, COLOR_BLACK, COLOR_CYAN); + init_pair(BBLUE, COLOR_BLACK, COLOR_BLUE); + init_pair(BYELLOW, COLOR_BLACK, COLOR_YELLOW); + init_pair(BGREEN, COLOR_BLACK, COLOR_GREEN); + init_pair(BMAGENTA, COLOR_BLACK, COLOR_MAGENTA); + init_pair(BRED, COLOR_BLACK, COLOR_RED); +} + + +void startProgramX() { + initscr(); // initialize curses + cbreak(); // pass key presses to program, but not signals + noecho(); // don't echo key presses to screen + keypad(stdscr, TRUE); // allow arrow keys + timeout(0); // no blocking on getch() + curs_set(0); // set the cursor to invisible + init_colors(); +} + +void stopProgramX() { + refresh(); + getch(); + endwin(); +} + + + +void Window::update() const{ + wrefresh(win); + wrefresh(frame); + refresh(); +} + + +Window::Window(int h,int w, int x, int y, char c) + : height(h), width(w), startx(x), starty(y), bord(c) +{ + colorwin=WCYAN; + colorframe=WBLACK; + frame=newwin(h+2,w+2,y,x); + win=subwin(frame,h,w,y+1,x+1); + wbkgd(frame,COLOR_PAIR(colorwin)); + wbkgd(win,COLOR_PAIR(colorframe)); + wborder(frame, c,c,c,c,c,c,c,c); + wattron(win,COLOR_PAIR(colorwin)); + wattron(frame,COLOR_PAIR(colorframe)); + update(); +} + +Window::~Window(){ + wborder(frame, ' ', ' ', ' ',' ',' ',' ',' ',' '); + wattroff(win,COLOR_PAIR(colorwin)); + wattroff(win,COLOR_PAIR(colorframe)); + werase(win); + update(); + delwin(win); +} + +void Window::print(int x, int y, std::string s, Color c) const { + wattron(win,COLOR_PAIR(c)); + mvwprintw(win,y,x,s.c_str()); + wattroff(win,COLOR_PAIR(c)); + update(); +} +void Window::print(int x, int y, char s, Color c) const{ + wattron(win,COLOR_PAIR(c)); + mvwaddch(win,y,x,s); + wattroff(win,COLOR_PAIR(c)); + update(); +} +void Window::print(int x, int y, std::string s) const{ + mvwprintw(win,y,x,s.c_str()); + update(); +} +void Window::print(int x, int y, char s) const{ + mvwaddch(win,y,x,s); + update(); +} + + +int Window::getX() const { return startx;} +int Window::getY() const { return starty;} +int Window::getHauteur() const { return height;} +int Window::getLargeur() const { return width;} +Color Window::getCouleurBordure() const{ return colorframe;} +Color Window::getCouleurFenetre() const{ return colorwin;} +void Window::setCouleurBordure(Color c){ + colorframe=c; + wattron(frame,COLOR_PAIR(colorframe)); + wborder(frame, bord,bord,bord,bord,bord,bord,bord,bord); + update(); +} +void Window::setCouleurFenetre(Color c){ + colorwin=c; + wattron(win,COLOR_PAIR(colorwin)); + wbkgd(win,COLOR_PAIR(colorwin)); + update(); +} + +void Window::clear() const{ werase(win); update(); } diff --git a/sem_3/project/Documents du Projet-20171011/window.h b/sem_3/project/Documents du Projet-20171011/window.h new file mode 100644 index 0000000..124e2eb --- /dev/null +++ b/sem_3/project/Documents du Projet-20171011/window.h @@ -0,0 +1,85 @@ +#ifndef __WINDOW_H +#define __WINDOW_H + +extern "C" { +#include +} +#include + +// Ensemble de couleurs possibles (fond+texte) +enum Color { + WBLACK, // couleur fond = noir , couleur texte = blanc + WCYAN, // couleur fond = cyan, couleur texte = blanc + WBLUE, // couleur fond = bleu, couleur texte = blanc + WYELLOW, // couleur fond = jaune, couleur texte = blanc + WGREEN, // couleur fond = vert, couleur texte = blanc + WMAGENTA,// couleur fond = magenta, couleur texte = blanc + WRED, // couleur fond = rouge, couleur texte = blanc + BWHITE, // couleur fond = blanc, couleur texte = blanc + BCYAN, // couleur fond = cyan, couleur texte = noir + BBLUE, // couleur fond = bleu, couleur texte = noir + BYELLOW, // couleur fond = jaune, couleur texte = noir + BGREEN, // couleur fond = vert, couleur texte = noir + BMAGENTA,// couleur fond = magenta, couleur texte = noir + BRED, // couleur fond = rouge, couleur texte = noir +}; + + + +// fonction pour demarrer le mode console graphique +void startProgramX(); +// fonction pour arreter le mode console graphique +void stopProgramX(); + + +class Window { + private: + int height,width,startx,starty; + WINDOW* win, *frame; + Color colorwin, colorframe; + char bord; + void update() const; + + public: + + // constructeur d'un fenetre de hauteur=h, largeur=w dont le coin superieur gauche + // a pour coordonnée (x,y), le caractère c est utilisé pour définir la bordure + Window(int h,int w, int x, int y, char c='+'); + + ~Window(); + + // fonction permettant d'afficher une variable s de type (string ou char) + // à la position (x,y) dans la fenetre. + // si un couleur est spécifié l'affichage utilise cette couleur, sinon la couleur de la fenêtre est utilisée + void print(int x, int y, std::string s, Color c) const; + void print(int x, int y, char s, Color c) const; + void print(int x, int y, std::string s) const; + void print(int x, int y, char s) const; + + + // accesseurs + int getX() const; // récupère l'abscisse du coin supérieur gauche de la fenêtre + int getY() const; // récupère l'ordonnée du coin supérieur gauche de la fenêtre + int getHauteur() const ; // récupère la hauteur de la fenêtre + int getLargeur() const ; // récupère la largeur de la fenêtre + + Color getCouleurBordure() const; // récupère la couleur de la bordure + Color getCouleurFenetre() const; // récupère la couleur de la fenêtre + void setCouleurBordure(Color); // modifie la couleur de la bordure + void setCouleurFenetre(Color); // modifie la couleur de la fenêtre (ATTENTION, tout le contenu de la fenêtre prend la couleur) + + void clear() const; // enleve tout le contenu de la fenêtre + +}; + + + + + + + + + + + +#endif -- cgit v1.2.3