Commit 653f7357c1b7128ee406040c8c55312d80da2de9
1 parent
71793b44
suppression
Showing
1 changed file
with
0 additions
and
84 deletions
Show diff stats
projet0.c deleted
... | ... | @@ -1,84 +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 | - /*for(int i = 0; i < 8; i++) { | |
21 | - tab[i+26].lettre = 130+i; //ajout caractères spéciaux | |
22 | - }*/ | |
23 | -} | |
24 | - | |
25 | -void ajout_tete(char elem, struct cell** pL) { | |
26 | - struct cell* p; | |
27 | - p = malloc(sizeof(struct cell)); | |
28 | - p->arbre = malloc(sizeof(struct node)); | |
29 | - p->arbre->lettre = elem; | |
30 | - p->suivant = *pL; | |
31 | - *pL = p; | |
32 | -} | |
33 | - | |
34 | -struct cell* insertion(char elem, struct cell** pL) { | |
35 | - if((*pL == NULL)||((*pL)->arbre->lettre > elem)) { | |
36 | - ajout_tete(elem, pL); | |
37 | - return (*pL)->arbre->listeFils; | |
38 | - } | |
39 | - else if((*pL)->arbre->lettre == elem) return (*pL)->arbre->listeFils; | |
40 | - else insertion(elem, &(*pL)->suivant); | |
41 | -} | |
42 | - | |
43 | -/*void affiche_tab(struct node tab[]) { | |
44 | - for(int i = 0; i < 32; i++) { | |
45 | - printf("%c\n", tab[i].lettre); | |
46 | - } | |
47 | - }*/ | |
48 | - | |
49 | -void lire_fichier(FILE* fd, struct node tab_arbre_prcp[]) { | |
50 | - struct cell* localisationArbre; | |
51 | - char motLu[50]; | |
52 | - int i = 0; | |
53 | - if(fd!=NULL) | |
54 | - { | |
55 | - while(fscanf(fd, "%s", motLu)==1) | |
56 | - { | |
57 | - if((caracLu[i] >= a) && (caracLu[i] <= z)) localisationArbre = tab_arbre_prcp[motLu[0]-97].listeFils; | |
58 | - | |
59 | - if(caracLu[i] == 39) localisationArbre = tab_arbre_prcp[A].listeFils; //A = derniere case du tab | |
60 | - while(motLu[i] != '\0') | |
61 | - { | |
62 | - i += 1; | |
63 | - localisationArbre = insertion(caracLu[i], tab_arbre_prcp[motlu[0]-97]); | |
64 | - } | |
65 | - | |
66 | - | |
67 | -} | |
68 | - | |
69 | -int main(int argc, char* argv[]) { | |
70 | - FILE* fd, | |
71 | - | |
72 | - struct node tab_arbre[A]; | |
73 | - struct node Arbre; | |
74 | - char lettre; | |
75 | - | |
76 | - if(argc>1) fd = fopen(argv[1], "r"); | |
77 | - | |
78 | - Arbre.listeLettre = NULL; | |
79 | - initialisation_tab_arbre(tab_arbre); | |
80 | - scanf("%c", &lettre); | |
81 | - insertion(lettre, &(Arbre.listeLettre)); | |
82 | - //printf("lettre : %c\n", Arbre.listeLettre->arbre->lettre); | |
83 | - return 0; | |
84 | -} |