un tableau et une matrice d'une liste chainée
Bonjour
bon j'ai le code suivant , son but est de crée un tableau d'une liste chainé
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define max_etat 10
#define max_etat_afd 20
typedef struct liste
{
int e;
struct liste *suiv;
}E_F;
/******************************************************************/
E_F *E[max_etat];
/******************************************************************/
void inserer_fin(E_F *tete,int ee){
E_F *lt,*p;
lt=(E_F*)malloc(sizeof(E_F));
lt->e=ee;
lt->suiv=NULL;
if(tete==NULL){
tete=lt;
}
else{
p=tete;
while(p->suiv!=NULL)p=p->suiv;
p->suiv=lt;
}
}
/******************************************************************/
/******************************************************************/
/******************************************************************/
/******************************************************************/
void afficher_E(E_F *l){
E_F *p;
p=l;
printf("|{");
while(p!=NULL){
printf("%d,",p->e);
p=p->suiv;
}
printf("}|");
}
/******************************************************************/
void inisialise(){
int i;
for(i=0;i<max_etat;i++)
inserer_fin(E[i],i);
}
void main(){
int i;
inisialise();
for(i=0;i<max_etat;i++)
afficher_E(E[i]);
} |
Normalment le code s'affiche : |{0}||{1}||{2}||{3}||{4}||{5}||{6}||{7}||{8}||{9}|
Mais il s'affiche : |{}||{}||{}||{}||{}||{}||{}||{}||{}||{}|
Et j'ai besoin de Crée un matrice d'une type list chainé exmple (E_F *matrice[10][10]) comment je peut l'initialisé et la manipulé ?!!!!