ou esce que tu affiche la table du dos?Envoyé par lucky31
ou esce que tu affiche la table du dos?Envoyé par lucky31
maintenant la table du dos m'affiche le menu mais tjrs le meme pb l'execution des tps ne s'affiche pas??
compiler puis executer puis la table du dos s'affiche
voici un code qui s'execute plus loin:
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263 #include <stdio.h> #include<stdlib.h> #define N 30 void tp1 (); void tp2 (); void tp3 (); void tp4 (); int choisir (); int Index (char s); char sommet [30]; char l2[30]; int l1[30]; int M[30][30]; int r,nb,nbr; char s; int main () { int r, nb, nbr = 0; int choix; do { choix = choisir (); if (choix=='1') tp1 (); if (choix=='2') tp2 (); if (choix=='3') tp3 (); //if (choix==4) tp4 (); } while (choix!=5); return 0; } int choisir () { int choix; printf ("tapez 1 pour effectuer le tp1 \n"); printf ("tapez 2 pour effectuer le tp2 \n"); printf ("tapez 3 pour effectuer le tp3 \n"); printf ("tapez 4 pour effectuer le tp4 \n"); printf ("tapez 5 pour sortir \n"); printf (" Donner votre choix: "); choix=getch(); return (choix); } //****************************************************************************** int Index (char s) { int r=0; int p; p=1; while ((sommet[p]!=s) && (sommet[p]!='*')) { p=p+1; } if (sommet[p]==s) { return(p); } else { r=r+1; sommet[r]=s; return (r); } } //****************************************************************************** void tp2 () {//tp1(); int i,j; char som1,som2; int nb=0; int nbr=0; char sommet[30]; int M[30][30]; printf ("donner le nombre de sommets : "); scanf ("%d\n",&nb); printf ("donner le nombre d'arcs : "); scanf ("%d\n",&nbr); //initialisation du tableau sommet for (i=1;i<=nb;i++) { sommet[i]= ' ' ; } //initialisation de la matrice M for (i=1;i<=nb;i++) for (j=1;j<=nb;j++) M[i][j]=0; //parcours en profondeur du graphe for (i=1;i<=nbr;i++) { int x,y; printf ("donner l'extremite initiale de l'arc \n: "); scanf ("%c",&som1); printf ("donner l'extremite terminale de l'arc \n: "); scanf ("%c",&som2); //x donne l'indice de som1 dans le tableau sommet x=Index(som1); // meme chose pour y y=Index(som2); M[x][y]=1; } //affichage de la matrice for (i=1;i<=nb;i++) { for (j=1;j<=nb;j++) printf ("%7d",M[i][j]); printf ("\n"); } tp1 (); } //****************************************************************************** void tp1 () { int i,j,k,d,nb,M[30][30],l1[30]; char sommet[30],l2[30]; k=0; //la lecture de la matrice sommet-sommet for(i=1;i<=nb;i++) { for(j=1;j<=nb;j++) { scanf( "%d",M[i][j]); } } //la lecture du tableau des sommets for (i=1;i<=nb;i++) { scanf ("%c" , sommet[i]); } //initialisation de la liste l2 for (i=1;i<=N ; i++) { l2[i]=' '; } //creation de la liste l2 for (i=1;i<=nb;i++) { for (j=1;j<=nb;j++) { if( M[i][j]==1) { printf (" le successeur du sommet : "); printf ("%c",sommet[i]); printf (" est : "); printf ("%c\n",sommet[j]); k=k+1; l2[k]=sommet[j]; } } } d=i; for (j=1;j<=nb;i++) { if (M[d][j]!=1) { k=k+1; l2[k]='*'; } } //affichage de la liste l2 for(i=1;i<=N;i++) { while (l2[i]!=' ' ) { printf("%c",l2[i]); printf (" "); } } //initialisation de la liste l1 for(i=1;i<N;i++) { l1[i]=0; } //creation de la liste l1 i=1; j=1; k=0; a:if(M[i][j]==1) { k=k+1; l1[k]=k; j=j+1; while(j<=nb) { b:if(M[i][j]==1) { k=k+1; j=j+1; goto b; } else { j=j+1; goto b; } } i=i+1; j=1; goto a; } else { j=j+1; goto a; } int p; p=k; for (i=1;i<=N;i++) { if(l2[i]=='*') { l1[p]=p; } } //affichage de la liste l1 for(i=1;i<=N;i++) { while (l1[i]!=0) { printf("%d",l1[i]); printf (" "); } } } //****************************************************************************** void tp3 () { int i,j,nb,M[30][30]; for (i=1;i<=nb;i++) { for (j=1;j<=nb;j++) { if ((M[i][j]==1)&&(i!=j)) { if ((M[j][i]==1)&&(i!=j)) { printf (" le graphe est symétrique "); printf ("\n"); } else printf (" le graphe est antisymetrique "); } if ((M[i][j]==0) && (M[j][i]==0)) { printf (" le graphe n'est complet "); printf ("\n"); } else printf("le graphe est complet"); } } } //return ; //}
ais vous pouvez m'aider a plus l'ameliorer
Je comprend pas trop ce que votre programme doit faire donc il va me faloir apredre et compredre pour pouvoir vous aider...Envoyé par lucky31
Cela ne fait que 1 an que je programme en C.
Je n'aurais pas forcement les competences necesaires!!!
Voila si vous aviez des explication simples et clairs...
ben mon prg est base sur les graphes, dans le 1 tp je dois afficher 2 listes 1 contient les successeurs et l'autre l'@ des successeurs
tp2 poser le graphe ds 1 matrice
pui tp3 si pour tester si le graphe est complet....
et j'ai pas encore fini tp4 car je dois implementer dijkstra et ford en utilisant la matrice qui contient le poid de chaque arcs merci
Ben non, c'est fait pour...Envoyé par crocodilex
http://emmanuel-delahaye.developpez....s.htm#globalesEnvoyé par miron
Manque les paramètres de fgets()...Envoyé par lucky31
le dernier code poster par miron vous pouvez essaye de le corriger encore svp
le prg est ecris en c est compiler avec le dev c++
Déjà, y'a ça :Envoyé par lucky31
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 Compiling: main.c main.c:4: warning: function declaration isn't a prototype main.c:5: warning: function declaration isn't a prototype main.c:6: warning: function declaration isn't a prototype main.c:7: warning: function declaration isn't a prototype main.c:8: warning: function declaration isn't a prototype main.c: In function `main_': main.c:20: warning: declaration of 'r' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c:20: warning: declaration of 'nb' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c:20: warning: declaration of 'nbr' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c:20: warning: unused variable `r' main.c:20: warning: unused variable `nb' main.c:20: warning: unused variable `nbr' main.c: At top level: main.c:34: warning: function declaration isn't a prototype main.c: In function `choisir': main.c:42: error: implicit declaration of function `getch' main.c:42: warning: nested extern declaration of `getch' main.c: At top level: main.c:48: warning: declaration of 's' shadows a global declaration main.c:16: warning: shadowed declaration is here main.c: In function `Index': main.c:51: warning: declaration of 'r' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c: At top level: main.c:73: warning: function declaration isn't a prototype main.c: In function `tp2': main.c:76: warning: declaration of 'nb' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c:77: warning: declaration of 'nbr' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c:78: warning: declaration of 'sommet' shadows a global declaration main.c:10: warning: shadowed declaration is here main.c:79: warning: declaration of 'M' shadows a global declaration main.c:13: warning: shadowed declaration is here main.c:102: warning: passing arg 1 of `Index' with different width due to prototype main.c:104: warning: passing arg 1 of `Index' with different width due to prototype main.c: At top level: main.c:118: warning: function declaration isn't a prototype main.c: In function `tp1': main.c:119: warning: declaration of 'nb' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c:119: warning: declaration of 'M' shadows a global declaration main.c:13: warning: shadowed declaration is here main.c:119: warning: declaration of 'l1' shadows a global declaration main.c:12: warning: shadowed declaration is here main.c:120: warning: declaration of 'sommet' shadows a global declaration main.c:10: warning: shadowed declaration is here main.c:120: warning: declaration of 'l2' shadows a global declaration main.c:11: warning: shadowed declaration is here main.c:127: warning: format argument is not a pointer (arg 2) main.c:133: warning: format argument is not a pointer (arg 2) main.c: At top level: main.c:234: warning: function declaration isn't a prototype main.c: In function `tp3': main.c:235: warning: declaration of 'nb' shadows a global declaration main.c:14: warning: shadowed declaration is here main.c:235: warning: declaration of 'M' shadows a global declaration main.c:13: warning: shadowed declaration is here main.c:262:4: warning: no newline at end of file Process terminated with status 1 (0 minutes, 1 seconds) 1 errors, 50 warnings
mais moi il m'affiche paas ces erreurs il va jusqu'a l'execution tu compile avec le dev c++?
Code:Blocks, mais c'est le même compilateur (gcc/MinGW)Envoyé par lucky31
Modifie tes paramètres du compilateur. Ajoute les options
Code : Sélectionner tout - Visualiser dans une fenêtre à part -Wall -Wextra -O2
A te forcer à être discipliné ,)
et comment les ajouter?
peut tu essaye de les corriger
man gccEnvoyé par lucky31
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager