Bonjour à tous, je dispose d'un fichier texte dico.txt dans lequel sont placés des mots séparés par des espaces:

artiste.art.soute.abime.sou.:

les 2 points marquent la fin du fichier, et le point simple marquant la fin d'un mot. je souhaite obtenir un graphe de ce type, avec un point dans la colonne 0, et dans la ligne suivant la fin d'un mot :

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
19
20
21
22
23
** Lecture du graphe
   0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20
0  _  a  _  _  _  _  _  _  s  _  _  _  _  _  _  _  _  _  _  _  _
1  _  _  r  _  _  _  _  _  _  _  _  _  _  b  _  _  _  _  _  _  _
2  _  _  _  t  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
3  .  _  _  _  i  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
4  _  _  _  _  _  s  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
5  _  _  _  _  _  _  t  _  _  _  _  _  _  _  _  _  _  _  _  _  _
6  _  _  _  _  _  _  _  e  _  _  _  _  _  _  _  _  _  _  _  _  _
7  .  _  _  _  _  _  _  _  _  o  _  _  _  _  _  _  _  _  _  _  _
8  _  _  _  _  _  _  _  _  _  _  u  _  _  _  _  _  _  _  _  _  _
9  .  _  _  _  _  _  _  _  _  _  _  t  _  _  _  _  _  _  _  _  _
10  _  _  _  _  _  _  _  _  _  _  _  _  e  _  _  _  _  _  _  _  _
11  .  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
12  _  _  _  _  _  _  _  _  _  _  _  _  _  _  i  _  _  _  _  _  _
13  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  m  _  _  _  _  _
14  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  e  _  _  _  _
15  .  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
16  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
17  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
18  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
19  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
20  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
Sur la premiere ligne, on peut débuter le parcours par A ou S,
Si on choisi A, on peut ensuite parcourir par R ou par B, etc...
le "." marque la fin d'un mot.
cependant, avec mon algo je n'obtient que ça :


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
19
20
21
22
   0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20
0  _  a  _  _  _  _  _  _  s  _  _  _  _  _  _  _  _  _  _  _  _
1  _  _  r  _  _  _  _  _  _  o  _  _  _  b  _  _  _  _  _  _  _
2  _  _  _  t  _  _  _  _  _  _  u  _  _  _  i  _  _  _  _  _  _
3  .  _  _  _  i  _  _  _  _  _  _  t  _  _  _  m  _  _  _  _  _
4  _  _  _  _  _  s  _  _  _  _  _  _  e  _  _  _  e  _  _  _  _
5  .  _  _  _  _  _  t  _  _  _  _  _  _  _  _  _  _  _  _  _  _
6  _  _  _  _  _  _  _  e  _  _  _  _  _  _  _  _  _  _  _  _  _
7  .  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
8  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
9  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
10  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
11  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
12  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
13  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
14  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
15  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
16  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
17  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
18  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
19  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
20  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _

Voici mon algorithme... si quelqu'un sait m'aider

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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
 
 
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
 
char* nom_fichier = "dico.txt" ;
 
const int max_sommets = 1000;
const int max_arcs = 5000 ;
 
typedef struct graphe_inc {
	char M [max_sommets][max_arcs] ;
	int nb_sommets ;
	int nb_arcs ;
} graphe_inc ;
graphe_inc G ;
 
void init_mat_inc ( ) 
// Initialisation d'une matrice
{ 
	G.nb_arcs = 0;
	G.nb_sommets = 0;
	for ( int i = 0 ; i < max_sommets ; i++ ) {
		for ( int j = 0 ; j < max_arcs ; j++ ) {
			G.M[i][j] = '_';
		}
	}
};
 
void lire_graphe ( ) 
{	ifstream source_graphe ( nom_fichier ) ;
	char tableau[5000];
	int ligne_courante = 0;
	int col_courante = 1;
	source_graphe >> tableau;
	int cpt = 0;
 
	// Tant que l'on arrive pas à la fin du dictionnaire
	while ( tableau[cpt] != ':' ) {
		// Si le caractère n'est pas un point '.'
		if ( tableau[cpt] != '.' ) {
            // On copie la valeur du caractère dans la matrice
			G.M[ligne_courante][col_courante] = tableau[cpt];
 
			// On incrémente les deux compteurs
			col_courante++;
			ligne_courante++;
			cpt++;
		}
 
		else {
			G.M[ligne_courante][0] = '.';
			ligne_courante = 0;
			int temp = cpt+1;
 
			for ( int i = 1 ; i <= col_courante ; i++ ) {
				if ( tableau[temp] == Ginc.M[ligne_courante][i] ) {
					ligne_courante++;
					temp++;
				}
			}
 
			cpt = temp;
		}
		G.nb_sommets++;
		G.nb_arcs++;
	}
 
};
 
void imprimer_mat_inc ( ) 
// Impression du contenu de G
{
	cout << "   ";
	for ( int cpt = 0 ; cpt < G.nb_sommets ; cpt++ ) { cout << cpt << "  "; }
	cout << endl;
	for ( int i = 0 ; i < G.nb_sommets ; i++ ) {
		cout << i << "  ";
		for ( int j = 0 ; j < G.nb_sommets ; j++ ) {
			cout << G.M[i][j] << "  ";
		}
		cout << endl;
	}
} ;
 
 
int main() 
{
	cout << "\n** Lecture du graphe\n" ;
	init_mat_inc ();
	lire_graphe () ; 
	imprimer_mat_inc () ;
 
system("PAUSE") ;
return 0;
}