From bdb6ac8daade79441360eca720d0735a0db90068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Thu, 9 Nov 2023 09:15:49 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20fonctions=20de=20d=C3=A9calage=20?= =?UTF-8?q?=C3=A0=20gauche/droite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/decalage.c | 25 +++++++++++++++++++++++++ src/main.h | 4 ++++ 2 files changed, 29 insertions(+) create mode 100644 src/decalage.c diff --git a/src/decalage.c b/src/decalage.c new file mode 100644 index 0000000..59ac7b5 --- /dev/null +++ b/src/decalage.c @@ -0,0 +1,25 @@ +/** + * @file decalage.c + * @brief Fonctions de décalage d'un tableau + * + * Contient les fonctions de décalage de tableau vers la droite (pour l'insertion) + * et vers la gauche (pour la suppression). +*/ + +#include "main.h" + +void decalageADroite(int tab[], int index, int tlog) +{ + for (int i = tlog; i > index; i--) + { + tab[i] = tab[i-1]; + } +} + +void decalageAGauche(int tab[], int index, int tlog) +{ + for (int i = index; i < tlog; i++) + { + tab[i] = tab[i+1]; + } +} \ No newline at end of file diff --git a/src/main.h b/src/main.h index 229ce29..7195831 100644 --- a/src/main.h +++ b/src/main.h @@ -27,6 +27,10 @@ void sauvegardeDonnees(int tLogArticle, int tLogClient, int reference[], float w void sauvegardeArticles(int reference[], float weight[], float volume[], float unitPrice[], int tLogArticle); void sauvegardeClients(int clientID[], int clientPassword[], float cagnotte[], int suspended[], int isAdmin[], int tLogClient); +//! DECALAGES TABLEAUX +void decalageADroite(int tab[], int index, int tlog); +void decalageAGauche(int tab[], int index, int tlog); + //! GESTION CLIENTS int inputClient(int clientID[], float cagnotte[], int suspended[], int isAdmin[], int *tlog); void modifyClient(int clientID[], float cagnotte[], int suspended[], int isAdmin[], int tlog);