Commit c01e116bf10b726e43dc39ee31ce308e8408706b
1 parent
54060a4d
Suppression fichiers inutiles
Showing
1 changed file
with
0 additions
and
91 deletions
Show diff stats
projet0.c~ deleted
@@ -1,91 +0,0 @@ | @@ -1,91 +0,0 @@ | ||
1 | -#include <stdio.h> | ||
2 | -#include <stdlib.h> | ||
3 | - | ||
4 | -#define A 26 | ||
5 | - | ||
6 | -struct node { | ||
7 | - char lettre; | ||
8 | - struct cell* listeFils; | ||
9 | -}; | ||
10 | - | ||
11 | -struct cell { | ||
12 | - struct node* arbre; | ||
13 | - struct cell* arbreSuivant; | ||
14 | -}; | ||
15 | - | ||
16 | -void initialisation_tab_arbre(struct node tab[]) { | ||
17 | - for(int i = 0; i < A; i++) { | ||
18 | - tab[i].lettre = 97+i; //ajout lettres minuscules | ||
19 | - } | ||
20 | - tab[A].lettre = 39; | ||
21 | - /*for(int i = 0; i < 8; i++) { | ||
22 | - tab[i+26].lettre = 130+i; //ajout caractères spéciaux | ||
23 | - }*/ | ||
24 | -} | ||
25 | - | ||
26 | -void ajout_tete(char elem, struct cell** pL) { | ||
27 | - struct cell* p; | ||
28 | - p = malloc(sizeof(struct cell)); | ||
29 | - p->arbre = malloc(sizeof(struct node)); | ||
30 | - p->arbre->lettre = elem; | ||
31 | - p->arbreSuivant = *pL; | ||
32 | - *pL = p; | ||
33 | -} | ||
34 | - | ||
35 | -struct cell* insertion(char elem, struct cell** pL) { | ||
36 | - if((*pL == NULL)||((*pL)->arbre->lettre > elem)) { | ||
37 | - ajout_tete(elem, pL); | ||
38 | - return (*pL)->arbre->listeFils; | ||
39 | - } | ||
40 | - else if((*pL)->arbre->lettre == elem) return (*pL)->arbre->listeFils; | ||
41 | - else insertion(elem, &(*pL)->arbreSuivant); | ||
42 | -} | ||
43 | - | ||
44 | -/*void affiche_tab(struct node tab[]) { | ||
45 | - for(int i = 0; i < 32; i++) { | ||
46 | - printf("%c\n", tab[i].lettre); | ||
47 | - } | ||
48 | - }*/ | ||
49 | - | ||
50 | -void lire_fichier(FILE* fd, struct node tab_arbre_prcp[]) { | ||
51 | - struct cell* localisationArbre; | ||
52 | - char motLu[50]; | ||
53 | - int i = 0; | ||
54 | - if(fd!=NULL) | ||
55 | - { | ||
56 | - while(fscanf(fd, "%s", motLu)==1) | ||
57 | - { | ||
58 | - if((motLu[i] >= 'a') && (motLu[i] <= 'z')) localisationArbre = tab_arbre_prcp[motLu[0]-97].listeFils; | ||
59 | - | ||
60 | - if(motLu[i] == 39) localisationArbre = tab_arbre_prcp[A].listeFils; //A = derniere case du tab | ||
61 | - while(motLu[i+1] != '\0') | ||
62 | - { | ||
63 | - i += 1; | ||
64 | - printf("lettre lue : %c\n", motLu[i]); | ||
65 | - localisationArbre = insertion(motLu[i], localisationArbre); | ||
66 | - } | ||
67 | - printf("\n"); | ||
68 | - } | ||
69 | - fclose(fd); | ||
70 | - } | ||
71 | -} | ||
72 | - | ||
73 | - | ||
74 | -int main(int argc, char* argv[]) { | ||
75 | - FILE* fd; | ||
76 | - | ||
77 | - struct node tab_arbre[A]; | ||
78 | - struct node Arbre; | ||
79 | - char lettre; | ||
80 | - | ||
81 | - if(argc>1) fd = fopen(argv[1], "r"); | ||
82 | - | ||
83 | - Arbre.listeFils = NULL; | ||
84 | - initialisation_tab_arbre(tab_arbre); | ||
85 | - lire_fichier(fd, tab_arbre); | ||
86 | - printf("tab_arbre[0].listeFils->arbre->lettre : %c\n", tab_arbre[0].listeFils->arbre->lettre); | ||
87 | - //scanf("%c", &lettre); | ||
88 | - //insertion(lettre, &(Arbre.listeFils)); | ||
89 | - //printf("lettre : %c\n", Arbre.listeFils->arbre->lettre); | ||
90 | - return 0; | ||
91 | -} |