Bonsoir,
Cela fait 3h que je coince sur un bout de code.
Je m'explique, j'ai un graphe avec des etats et des arcs. Je veux coder une fonction qui me supprimer un arc donner d'un certain etat.
Voici la structure :
Et la fonction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 typedef struct { int symbol; int destination; } Arc; typedef struct { int num_arcs; bool is_final; Arc* arcs; } State; typedef struct { int num_states; int initial_state; State* states; } Automaton;
Lorsque j’exécute cette fonction, il y a toujours autant d'arcs...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 /*Suprimme une transition de l'automate*/ void rm_arc(Automaton *a, int from, int to, int symbol){ if(has_arc(a, from, to, symbol) == TRUE){ int i=0; while(a->states[from].arcs[i].destination!=to && a->states[from].arcs[i].symbol!=symbol && i<a->states[from].num_arcs){ i++; } free(&a->states[from].arcs[i]); } }
Merci d'avance
Partager