#include <stdio.h>
#include <stdlib.h>

struct noeud {
    struct noeud* precedent;
    int valeur;
    struct noeud* suivant;
}

struct file{
    struct noeud* debut;
    struct noeud* fin;
}

typedef struct file_s file:

file initFile();
bool fileVide(file f);
file enfiler(file f, int x);
int tete(file f);
file defiler(file f);

//Initialisation
file initFile(){
    file f;
    f.debut = NULL;
    f.fin = NULL;
    return f;
}

//Si la file est vide
bool fileVide(file f){
    return f.debut == NULL;
}

//Enfiler un élément
file enfiler(file f, int x){
    struct noeud* nv = malloc(sizeof(struct noeud));
    nv->valeur = x;
    nv->precedent = NULL;
    if (f.debut == NULL){
        nv->suivant = NULL;
        f.debut = nv;
        f.fin = nv;
    }
    else {
        f.debut->precedent = nv;
        nv->suivant = f.debut;
        f.debut = nv;
    }
    return f;
}

//Tête de file
int tete(file f){
    return f.fin->valeur;
}

//Défiler le dernier
file defiler(file f){
    if (f.debut == NULL){
        fprintf(stderr,"Impossibe de défiler une file vide \n");
        exit(EXIT_FAILURE);
    }
    f.fin = f.fin->precedent;
    free(f.fin->suivant);
    f.fin->suivant = NULL;
}

int main(){
    return EXIT_SUCCESS;
}





















Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: