diff --git a/Algo/tp/tp10/resultat.bin b/Algo/tp/tp10/resultat.bin index 16e858c..5f90cc5 100755 Binary files a/Algo/tp/tp10/resultat.bin and b/Algo/tp/tp10/resultat.bin differ diff --git a/Algo/tp/tp11/exe b/Algo/tp/tp11/exe index deb18f3..29ae143 100755 Binary files a/Algo/tp/tp11/exe and b/Algo/tp/tp11/exe differ diff --git a/Algo/tp/tp12/exe b/Algo/tp/tp12/exe new file mode 100755 index 0000000..65de09e Binary files /dev/null and b/Algo/tp/tp12/exe differ diff --git a/Algo/tp/tp12/matieres.bin b/Algo/tp/tp12/matieres.bin new file mode 100644 index 0000000..242914f Binary files /dev/null and b/Algo/tp/tp12/matieres.bin differ diff --git a/Algo/tp/tp12/matieres.txt b/Algo/tp/tp12/matieres.txt new file mode 100644 index 0000000..9b2795b --- /dev/null +++ b/Algo/tp/tp12/matieres.txt @@ -0,0 +1,6 @@ +acsi1 4 analyse et conception +algo1 4 algorithme périodique 1 +algo2 4 algorithme périodique 2 +based 4 base de données +maths 2 mathématiques +organ 2 organisation diff --git a/Algo/tp/tp12/testtp12.c b/Algo/tp/tp12/testtp12.c new file mode 100644 index 0000000..7778f0c --- /dev/null +++ b/Algo/tp/tp12/testtp12.c @@ -0,0 +1,21 @@ +#include "tp12.h" + +void testCharge(void) +{ + Mat *tab[50]; + int nb; + char nomFich[20]; + printf("Donnez le nom du fichier :\n"); + scanf("%s", nomFich); + nb = chargeFmatieres(nomFich, tab, 50); + if(nb < 0) + return; + afficheTmat(tab, nb); +} + +int main(void) +{ + //testCharge(); + global(); + return 0; +} \ No newline at end of file diff --git a/Algo/tp/tp12/tp12.c b/Algo/tp/tp12/tp12.c new file mode 100644 index 0000000..12756c5 --- /dev/null +++ b/Algo/tp/tp12/tp12.c @@ -0,0 +1,146 @@ +#include "tp12.h" + +int chargeFmatieres(char *nomFich, Mat **tmat, int tmax) +{ + int i = 0; + Mat m; + FILE *flot; + printf("%d\n", i); + flot = fopen(nomFich, "r"); + if(flot == NULL) + { + printf("Pb d'ouverture du fichier %s.\n", nomFich); + return -1; + } + m = lireMat(flot); + while(!feof(flot)) + { + if(i == tmax) + { + printf("tbl plein !!!\n"); + fclose(flot); + return -2; + } + tmat[i] = (Mat *)malloc(sizeof(Mat)); + if(tmat[i] == NULL) + { + printf("Pb du tableau !\n"); + fclose(flot); + return -3; + } + *tmat[i] = m; + i = i +1; + m = lireMat(flot); + } + fclose(flot); + return i; +} + +Mat lireMat(FILE *flot) +{ + Mat m; + fscanf(flot, "%s%d", m.code, &m.coef); + fgets(m.design, 30, flot); + m.design[strlen(m.design)-1] = '\0'; + return m; +} + +void afficheMat(Mat m) +{ + printf("%s\t%d\t%s\n", m.code, m.coef, m.design); +} + +void afficheTmat(Mat **tMat, int nbmat) +{ + int i; + for(i = 0; i < nbmat; i++) + afficheMat(*tMat[i]); + printf("\n"); +} + +void libereEspaceA(Mat *tmat[], int nb) +{ + int i; + for(i = 0; i < nb; i++) + free(tmat[i]); +} + +void sauvTbin(Mat *tab[], int nb) +{ + int i; + FILE *flot; + flot = fopen("matieres.bin", "wb"); + if(flot == NULL) + { + printf("Pb d'ouverture du fichier matieres.bin"); + return; + } + fprintf(flot, "%d\n", &nb); + for(i = 0; i < nb; i++) + fwrite(tab[i], sizeof(Mat), 1, flot); + fclose(flot); +} + +int rechdich(char *code, Mat **tmat, int nbmat, int *trouve) +{ + int inf, sup, m; + inf = 0; + sup = nbmat -1; + while(inf <= sup) + { + m = (inf + sup)/2; + if(strcmp(code, tmat[m]->code) == 0) + { + *trouve = 1; + return m; + } + if(strcmp(code, tmat[m]->code) < 0) + sup = m - 1; + else inf = m+ 1; + } + *trouve = 0; + return inf; +} + +int supprime(Mat **tMat, int nbmat) +{ + char code[6], rep; + int pas, trouve, i; + printf("Donnez le code de la matière à supprimer :\n"); + scanf("%s%*c", code); + pas = rechdich(code, tMat, nbmat, &trouve); + if(trouve == 0) + printf("Aucune matière n'as été trouvé\n"); + else{ + afficheMat(*tMat[pas]); + printf("Vouez vous vraiment supprimer ? :\n"); + scanf("%c", &rep); + if(rep == 'o') + { + free(tMat[pas]); + for(i = pas; i < nbmat-1; i++) + tMat[i] = tMat[i + 1]; + nbmat = nbmat - 1; + } + } + return nbmat; +} + +void global(void) +{ + Mat *tab[50]; + int nb; + char nomFich[20]; + printf("Donnez le nom du fichier :\n"); + scanf("%s", nomFich); + nb = chargeFmatieres(nomFich, tab, 50); + if(nb < 0) + return; + afficheTmat(tab, nb); + nb = supprime(tab, nb); + afficheTmat(tab, nb); + nb = supprime(tab, nb); + afficheTmat(tab, nb); + sauvTbin(tab, nb); + libereEspaceA(tab, nb); +} \ No newline at end of file diff --git a/Algo/tp/tp12/tp12.h b/Algo/tp/tp12/tp12.h new file mode 100644 index 0000000..d692dd3 --- /dev/null +++ b/Algo/tp/tp12/tp12.h @@ -0,0 +1,20 @@ +#include +#include +#include + +typedef struct { + char code[6]; + int coef; + char design[32]; +} Mat; + +int chargeFmatieres(char *nomFich, Mat **tmat, int tmax); +void global(void); +Mat lireMat(FILE *flot); +void afficheMat(Mat m); +void afficheTmat(Mat **tMat, int nbmat); +void libereEspaceA(Mat *tmat[], int nb); +void sauvTbin(Mat *tab[], int nb); +int rechdich(char *code, Mat **tmat, int nbmat, int *trouve); +int supprime(Mat **tMat, int nbmat); +void testCharge(void); \ No newline at end of file diff --git a/Algo/tp/tp8/Final/fichierMots.txt b/Algo/tp/tp8/Final/fichierMots.txt index e9f83bf..0dd6a0f 100755 --- a/Algo/tp/tp8/Final/fichierMots.txt +++ b/Algo/tp/tp8/Final/fichierMots.txt @@ -1,3 +1,4 @@ +bai baie bail bailler diff --git a/Algo/tp/tp8/Final/tp8.c b/Algo/tp/tp8/Final/tp8.c index 77ce0d7..1315939 100755 --- a/Algo/tp/tp8/Final/tp8.c +++ b/Algo/tp/tp8/Final/tp8.c @@ -250,7 +250,7 @@ void chercher(char tab[][27], int nb, char mot[]) if (tab[i][j] == mot[k] && num[k] == 0) { num[k] = 1; - pass=1; + pass = 1; break; } } diff --git a/Algo/tp/tp8/exe b/Algo/tp/tp8/exe deleted file mode 100755 index 455e92c..0000000 Binary files a/Algo/tp/tp8/exe and /dev/null differ diff --git a/Algo/tp/tp8/tp8.c b/Algo/tp/tp8/tp8.c index 4825ce8..ba4cae5 100755 --- a/Algo/tp/tp8/tp8.c +++ b/Algo/tp/tp8/tp8.c @@ -107,10 +107,9 @@ int compterLettres(char mot[]) /* Exercice 3 */ -void chargement(int tMot[][nbMots]) +void chargement(int tMot[], int nbMots) { int i = 0, j; - FILE *flot; flot = fopen("mots.don", "r"); if (flot == NULL) diff --git a/Algo/tp/tp8/tp8.h b/Algo/tp/tp8/tp8.h index f9f584d..1961441 100755 --- a/Algo/tp/tp8/tp8.h +++ b/Algo/tp/tp8/tp8.h @@ -7,4 +7,4 @@ void initialiser(char mot[], int n); void placer(char mot1[], char c, char mot2[]); void jeuPendu(void); int compterLettres(char mot[]); -void chargement(int tMot); \ No newline at end of file +//void chargement(int tMot, int nbMots); \ No newline at end of file diff --git a/Algo/tp/tp9/matieres.txt b/Algo/tp/tp9/matieres.txt index 01b8b88..b80f8b1 100755 --- a/Algo/tp/tp9/matieres.txt +++ b/Algo/tp/tp9/matieres.txt @@ -3,3 +3,4 @@ maths 2 mathématiques maths 4 maths 5 math 5 sdjlkgf sdkjgf 55dsf +algo1 8 algorithme diff --git a/BDD/tp/tp8/tp8.sql b/BDD/tp/tp8/tp8.sql index e108a60..2b89b51 100644 --- a/BDD/tp/tp8/tp8.sql +++ b/BDD/tp/tp8/tp8.sql @@ -222,13 +222,13 @@ UPDATE DRAGON SET num_terr = 'T03' WHERE numD = 'D0008'; /* SELECT NOURRITURE.nom FROM NOURRITURE JOIN REPAS ON NOURRITURE.numn = REPAS.numn JOIN DRAGON ON REPAS.numd = DRAGON.numd JOIN AMOUR ON DRAGON.numD = AMOUR.numDragon1 WHERE DRAGON.longeur>200 AND AMOUR.force = 'un peu'; */ /* Question 12 */ -/* SELECT DRAGON.nom FROM DRAGON JOIN AMOUR ON DRAGON.numD = AMOUR.numDragon1 */ +/* SELECT aimant.nom, aime.nom FROM DRAGON aimant JOIN AMOUR ON aimant.numD = AMOUR.numDragon1 JOIN DRAGON AS aime ON AMOUR.numDragon2 = aime.numD; */ /* Question 13 */ /* SELECT DISTINCT DRAGON.nom FROM DRAGON JOIN REPAS ON DRAGON.numD = REPAS.numD JOIN NOURRITURE ON REPAS.numN = NOURRITURE.numN WHERE NOURRITURE.nom = 'Oeuf' AND DRAGON.numD NOT IN (SELECT DRAGON.numD FROM DRAGON JOIN REPAS ON DRAGON.numD = REPAS.numD JOIN NOURRITURE ON REPAS.numN = NOURRITURE.numN WHERE NOURRITURE.nom = 'Orange'); */ /* Question 14 */ -/* +/* */