This commit is contained in:
Lukian LEIZOUR 2023-11-29 22:55:40 +01:00
parent bd738652a5
commit 031b51a916
10 changed files with 172 additions and 146 deletions

View file

@ -1,23 +0,0 @@
@echo off
setlocal
:: Vérifier si Dev-Cpp est installé
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Dev-Cpp" >nul 2>&1
if %errorlevel% equ 0 (
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Dev-Cpp" /v Location ^| find "Location"') do (
set "mingwBin=%%b\MinGW64\bin"
)
:: Ajouter le chemin vers le bin de MinGW à la variable d'environnement PATH
echo %PATH% | find "%mingwBin%" >nul
if not errorlevel 1 (
echo Le chemin d'accès aux bin de MinGW est déjà présent dans la variable d'environnement PATH.
) else (
setx PATH "%PATH%;%mingwBin%" -m
echo Le chemin d'accès aux bin de MinGW a été ajouté à la variable d'environnement PATH.
)
) else (
echo Dev-Cpp n'est pas installé sur cet ordinateur.
)
endlocal

128
conf.c
View file

@ -21,7 +21,9 @@ int findConfId(ptConf confChain) {
ptConf newConfChain() { ptConf newConfChain() {
ptConf confChain = (ptConf) malloc(sizeof(tConf)); ptConf confChain = (ptConf) malloc(sizeof(tConf));
confChain -> next = NULL; confChain -> next = (ptConf) malloc(sizeof(tConf));
confChain -> next -> next = NULL;
confChain -> id = -1;
return confChain; return confChain;
} }
@ -40,7 +42,9 @@ void addConf(ptConf confChain, int id, char title[], char speaker[], int day, in
strcpy(px -> title, title); strcpy(px -> title, title);
strcpy(px -> speaker, speaker); strcpy(px -> speaker, speaker);
px -> listeners = (ptListenerList) malloc(sizeof(tListenerList)); px -> listeners = (ptListenerList) malloc(sizeof(tListenerList));
px -> listeners -> next = NULL; px -> listeners -> next = (ptListenerList) malloc(sizeof(tListenerList));
px -> listeners -> listener = NULL;
px -> listeners -> next -> next = NULL;
px -> next = (ptConf) malloc(sizeof(tConf)); px -> next = (ptConf) malloc(sizeof(tConf));
px -> next -> next = NULL; px -> next -> next = NULL;
} }
@ -48,44 +52,21 @@ void addConf(ptConf confChain, int id, char title[], char speaker[], int day, in
void removeConf(ptConf confChain, int id) { void removeConf(ptConf confChain, int id) {
ptConf px = confChain; ptConf px = confChain;
if (px -> next -> next == NULL) {
ptListenerList py = px -> listeners;
while (py -> next != NULL) {
ptConfList pz = py -> listener -> confs;
while (pz -> next != NULL) {
if (pz -> next -> next )
pz = pz -> next;
}
py = py -> next;
}
free(px -> next);
px -> next = NULL;
} else if (px -> id == id) {
px -> id = px -> next -> id;
strcpy(px -> title, px -> next -> title);
strcpy(px -> speaker, px -> next -> speaker);
px -> day = px -> next -> day;
px -> month = px -> next -> month;
px -> year = px -> next -> year;
ptConf tmp = px -> next;
px -> next = px -> next -> next;
free(tmp);
} else {
while (px -> next != NULL && px -> next -> id != id) { while (px -> next != NULL && px -> next -> id != id) {
px = px -> next; px = px -> next;
} }
if (px -> next -> id == id) { if (px -> next != NULL && px -> next -> id == id) {
ptConf tmp = px -> next; ptListenerList py = px -> next -> listeners -> next;
px -> next = px -> next -> next;
free(tmp); while (py -> next != NULL) {
removeConfFromConfList(py -> listener -> confs, px -> next);
py = py -> next;
} }
ptConf tmp = px -> next -> next;
free(px -> next);
px -> next = tmp;
} }
} }
@ -108,7 +89,9 @@ ptListener newListenerChain() {
ptListener listenerChain = (ptListener) malloc(sizeof(tListener)); ptListener listenerChain = (ptListener) malloc(sizeof(tListener));
listenerChain -> prev = NULL; listenerChain -> prev = NULL;
listenerChain -> next = NULL; listenerChain -> next = (ptListener) malloc(sizeof(tListener));
listenerChain -> next -> prev = listenerChain;
listenerChain -> id = -1;
return listenerChain; return listenerChain;
} }
@ -129,7 +112,9 @@ int addListener(ptListener listenerChain, int id, char name[], int age, int leve
px -> age = age; px -> age = age;
px -> level = level; px -> level = level;
px -> confs = (ptConfList) malloc(sizeof(tConfList)); px -> confs = (ptConfList) malloc(sizeof(tConfList));
px -> confs -> next = NULL; px -> confs -> next = (ptConfList) malloc(sizeof(tConfList));
px -> confs -> conf = NULL;
px -> confs -> next -> next = NULL;
px -> next = (ptListener) malloc(sizeof(tListener)); px -> next = (ptListener) malloc(sizeof(tListener));
px -> next -> next = NULL; px -> next -> next = NULL;
px -> next -> prev = px; px -> next -> prev = px;
@ -139,30 +124,22 @@ int addListener(ptListener listenerChain, int id, char name[], int age, int leve
void removeListener(ptListener listenerChain, int id) { void removeListener(ptListener listenerChain, int id) {
ptListener px = listenerChain; ptListener px = listenerChain;
if (px -> next -> next == NULL) {
free(px -> next);
px -> next = NULL;
} else if (px -> id == id) {
px -> id = px -> next -> id;
strcpy(px -> name, px -> next -> name);
px -> age = px -> next -> age;
px -> level = px -> next -> level;
ptListener tmp = px -> next;
px -> next = px -> next -> next;
px -> next -> prev = px;
free(tmp);
} else {
while (px -> next != NULL && px -> next -> id != id) { while (px -> next != NULL && px -> next -> id != id) {
px = px -> next; px = px -> next;
} }
if (px -> next -> id == id) { if (px -> next != NULL && px -> next -> id == id) {
ptListener tmp = px -> next; ptConfList py = px -> next -> confs -> next;
px -> next = px -> next -> next;
px -> next -> prev = px; while (py -> next != NULL) {
free(tmp); removeListenerFromListenerList(py -> conf -> listeners, px -> next);
py = py -> next;
} }
ptListener tmp = px -> next -> next;
free(px -> next);
px -> next = tmp;
px -> next -> prev = px;
} }
} }
@ -179,6 +156,25 @@ void addConfToConfList(ptConfList confList, ptConf conf, int grade) {
px -> next -> next = NULL; px -> next -> next = NULL;
} }
void removeConfFromConfList(ptConfList confList, ptConf conf) {
ptConfList px = confList;
while (px -> next != NULL && px -> conf != conf) {
px = px -> next;
}
printConfList(confList -> next);
printf("%d\n", px -> conf -> id);
if (px -> next != NULL && px -> next -> conf == conf) {
ptConfList tmp = px -> next -> next;
free(px -> next);
px -> next = tmp;
}
system("pause");
}
void printConfList(ptConfList confList) { void printConfList(ptConfList confList) {
ptConfList px = confList; ptConfList px = confList;
@ -203,6 +199,20 @@ void addListenerToListenerList(ptListenerList listenerList, ptListener listener,
px -> next -> next = NULL; px -> next -> next = NULL;
} }
void removeListenerFromListenerList(ptListenerList listenerList, ptListener listener) {
ptListenerList px = listenerList;
while (px -> next != NULL && px -> listener != listener) {
px = px -> next;
}
if (px -> next != NULL && px -> next -> listener == listener) {
ptListenerList tmp = px -> next -> next;
free(px -> next);
px -> next = tmp;
}
}
void printListenerList(ptListenerList listenerList) { void printListenerList(ptListenerList listenerList) {
ptListenerList px = listenerList; ptListenerList px = listenerList;
@ -227,7 +237,7 @@ int participateToConf(ptConf confChain, ptListener listenerChain, int confId, in
px = px -> next; px = px -> next;
} }
pz = px -> listeners; pz = px -> listeners -> next;
while (pz -> next != NULL) { while (pz -> next != NULL) {
if (pz -> listener -> id == listenerId) { if (pz -> listener -> id == listenerId) {
return -2; return -2;
@ -250,7 +260,7 @@ int participateToConf(ptConf confChain, ptListener listenerChain, int confId, in
} }
int confGradeAvg(ptConf conf) { int confGradeAvg(ptConf conf) {
ptListenerList px = conf -> listeners; ptListenerList px = conf -> listeners -> next;
int total = 0, nb = 0; int total = 0, nb = 0;
while (px -> next != NULL) { while (px -> next != NULL) {
@ -268,7 +278,7 @@ int confGradeAvg(ptConf conf) {
} }
int confParticipations(ptConf conf) { int confParticipations(ptConf conf) {
ptListenerList px = conf -> listeners; ptListenerList px = conf -> listeners -> next;
int nb = 0; int nb = 0;
while (px -> next != NULL) { while (px -> next != NULL) {

2
conf.h
View file

@ -50,8 +50,10 @@ ptListener newListenerChain();
int addListener(ptListener listenerChain, int id, char name[], int age, int level); int addListener(ptListener listenerChain, int id, char name[], int age, int level);
void removeListener(ptListener listenerChain, int id); void removeListener(ptListener listenerChain, int id);
void addConfToConfList(ptConfList confList, ptConf conf, int grade); void addConfToConfList(ptConfList confList, ptConf conf, int grade);
void removeConfFromConfList(ptConfList confList, ptConf conf);
void printConfList(ptConfList confList); void printConfList(ptConfList confList);
void addListenerToListenerList(ptListenerList listenerList, ptListener listener, int grade); void addListenerToListenerList(ptListenerList listenerList, ptListener listener, int grade);
void removeListenerFromListenerList(ptListenerList listenerList, ptListener listener);
void printListenerList(ptListenerList listenerList); void printListenerList(ptListenerList listenerList);
int participateToConf(ptConf confChain, ptListener listenerChain, int confId, int listenerId, int grade); int participateToConf(ptConf confChain, ptListener listenerChain, int confId, int listenerId, int grade);
int confGradeAvg(ptConf conf); int confGradeAvg(ptConf conf);

View file

@ -1,4 +1,3 @@
1,Rapport_du_GIEC,Jean_Jouzzel,15,11,2022
2,L_esprit_critique,Thomas_Durand,6,2,2023 2,L_esprit_critique,Thomas_Durand,6,2,2023
3,La_resilience,Arthur_Keller,20,10,2022 3,La_resilience,Arthur_Keller,20,10,2022
4,American_lobbying,Salah_Oueslati,30,11,2023 4,American_lobbying,Salah_Oueslati,30,11,2023
@ -9,3 +8,4 @@
9,Le_lacet_irlandais,Mick_Oconnell,31,3,2022 9,Le_lacet_irlandais,Mick_Oconnell,31,3,2022
10,Litterature_et_SF,Terry_Pratchett,15,5,2021 10,Litterature_et_SF,Terry_Pratchett,15,5,2021
11,Les_chaises_en_bois,David,24,12,2023 11,Les_chaises_en_bois,David,24,12,2023
12,cybersecurite_des_coquillages,Bob,6,2,2024

View file

@ -1,2 +1,5 @@
1:12;0,1;4 1:12;0,1;4
2:12;0,1;4
3:12;0,1;4
4:12;0,1;4
9:20;5 9:20;5

View file

@ -9,3 +9,4 @@
9,Le_lacet_irlandais,Mick_Oconnell,31,3,2022 9,Le_lacet_irlandais,Mick_Oconnell,31,3,2022
10,Litterature_et_SF,Terry_Pratchett,15,5,2021 10,Litterature_et_SF,Terry_Pratchett,15,5,2021
11,Les_chaises_en_bois,David,24,12,2023 11,Les_chaises_en_bois,David,24,12,2023
12,cybersecurite_des_coquillages,Bob,6,2,2024

BIN
main.exe

Binary file not shown.

View file

@ -113,14 +113,14 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
{ {
case 1: case 1:
{ {
ptConf px = confChain; ptConf px = confChain -> next;
while (px -> next != NULL) { while (px -> next != NULL) {
printf("Id : %d\nTitre : %s\nConferencier : %s\n", px -> id, px -> title, px -> speaker); printf("Id : %d\nTitre : %s\nConferencier : %s\n", px -> id, px -> title, px -> speaker);
printf("Date : %d/%d/%d\n",px -> day, px -> month, px -> year); printf("Date : %d/%d/%d\n",px -> day, px -> month, px -> year);
printf("Nombre de participants : %d\n", confParticipations(px)); printf("Nombre de participants : %d\n", confParticipations(px));
if (px -> listeners -> next != NULL ) { if (px -> listeners -> next != NULL ) {
printListenerList(px -> listeners); printListenerList(px -> listeners -> next);
} }
int avg; int avg;
if ((avg = confGradeAvg(px) != -1)) { if ((avg = confGradeAvg(px) != -1)) {
@ -153,7 +153,7 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
scanf("%d", &year); scanf("%d", &year);
addConf(confChain, id, title, speaker, day, month, year); addConf(confChain, id, title, speaker, day, month, year);
saveConf(confChain); saveConf(confChain -> next);
menuConf(confChain, listenerChain); menuConf(confChain, listenerChain);
break; break;
} }
@ -166,7 +166,7 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
scanf("%d", &id); scanf("%d", &id);
removeConf(confChain, id); removeConf(confChain, id);
saveConf(confChain); saveConf(confChain -> next);
menuConf(confChain, listenerChain); menuConf(confChain, listenerChain);
break; break;
} }
@ -197,7 +197,7 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
} }
} }
saveConf(confChain); saveConf(confChain -> next);
menuConf(confChain, listenerChain); menuConf(confChain, listenerChain);
} }
@ -224,12 +224,12 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
{ {
case 1: case 1:
{ {
ptListener py = listenerChain; ptListener py = listenerChain -> next;
while (py -> next != NULL) { while (py -> next != NULL) {
printf("Id : %d\nNom: %s\nAge: %d\nNiveau: %d\n", py -> id, py -> name, py -> age, py -> level); printf("Id : %d\nNom: %s\nAge: %d\nNiveau: %d\n", py -> id, py -> name, py -> age, py -> level);
if (py -> confs -> next != NULL) { if (py -> confs -> next != NULL) {
printConfList(py -> confs); printConfList(py -> confs -> next);
} }
printf("\n"); printf("\n");
py = py -> next; py = py -> next;
@ -253,7 +253,7 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
scanf("%d", &level); scanf("%d", &level);
if (addListener(listenerChain, id, name, age, level) != -1) { if (addListener(listenerChain, id, name, age, level) != -1) {
saveListeners(listenerChain); saveListeners(listenerChain -> next);
} else { } else {
printf("Le niveau de l'abonne doit etre compris entre 0 et 5.\n\n"); printf("Le niveau de l'abonne doit etre compris entre 0 et 5.\n\n");
system("pause"); system("pause");
@ -270,7 +270,7 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
scanf("%d", &id); scanf("%d", &id);
removeListener(listenerChain, id); removeListener(listenerChain, id);
saveListeners(listenerChain); saveListeners(listenerChain -> next);
menuAbo(confChain, listenerChain); menuAbo(confChain, listenerChain);
break; break;
} }

View file

@ -119,28 +119,17 @@ void removeConf(ptConf confChain, int id)
{ {
ptConf px = confChain; ptConf px = confChain;
if (px->next->next == NULL) if (px->next == NULL)
{ {
ptListenerList py = px->listeners; return;
while (py->next != NULL)
{
ptConfList pz = py->listener->confs;
while (pz->next != NULL)
{
if (pz->next->next)
pz = pz->next;
}
py = py->next;
} }
else if (px->next->next == NULL)
{
free(px->next); free(px->next);
px->next = NULL; px->next = NULL;
} }
else if (px->id == id) else if (px->id == id && px->next->next != NULL)
{ {
px->id = px->next->id; px->id = px->next->id;
strcpy(px->title, px->next->title); strcpy(px->title, px->next->title);
@ -226,8 +215,11 @@ int addListener(ptListener listenerChain, int id, char name[], int age, int leve
void removeListener(ptListener listenerChain, int id) void removeListener(ptListener listenerChain, int id)
{ {
ptListener px = listenerChain; ptListener px = listenerChain;
if (px->next == NULL)
if (px->next->next == NULL) {
return;
}
else if (px->id == id && px->next->next == NULL)
{ {
free(px->next); free(px->next);
px->next = NULL; px->next = NULL;
@ -276,6 +268,47 @@ void addConfToConfList(ptConfList confList, ptConf conf, int grade)
px->next->next = NULL; px->next->next = NULL;
} }
void removeConfFromConfList(ptConf confChain, ptConfList confList, ptConf conf)
{
if (confList->next == NULL)
{
return;
}
else if (confList->next->next == NULL && confList->conf == conf)
{
free(confList->next);
confList->next = NULL;
}
else if (confList->conf == conf && confList->next->next != NULL)
{
confList->conf = confList->next->conf;
confList->grade = confList->next->grade;
ptConfList tmp = confList->next->next;
free(confList->next);
confList->next = tmp;
}
else
{
ptConfList px = confList;
while (px->next != NULL && px->next->conf != conf)
{
if (confChain == conf && px->conf == conf->next) {
px->conf
}
px = px->next;
}
if (px->next->conf == conf) {
ptConfList tmp = px->next->next;
free(px->next);
px->next = tmp;
}
}
}
void printConfList(ptConfList confList) void printConfList(ptConfList confList)
{ {
ptConfList px = confList; ptConfList px = confList;

BIN
singleFile.exe Normal file

Binary file not shown.