bonjour a tous, j"'ai un gros probleme avec ce program ; ya aucune error logique , mais ca marche pa ;
mercii de me dire si il ya qlq chose a revise ;mercii d'avance .
bonjour a tous, j"'ai un gros probleme avec ce program ; ya aucune error logique , mais ca marche pa ;
mercii de me dire si il ya qlq chose a revise ;mercii d'avance .
Voila déjà deux choses à réviser:Envoyé par micka55
-des commentaires
-une explication de la fonctionnalité de ton programme
à partir de là on pourra juger s'il n'y a effectivement pas d' "error logique".
Est-ce suffisamment clair ?Envoyé par micka55
Pour obtenir ces messages, un meilleur réglage de ton compilateur est peut être nécessaire :
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 Project : Forums Compiler : GNU GCC Compiler (called directly) Directory : C:\dev\forums\ -------------------------------------------------------------------------------- Switching to target: default Compiling: main.c main.c: In function `main': main.c:16: warning: unused variable `i' main.c: In function `decode': main.c:67: warning: unused variable `J' main.c:77: warning: unused variable `j' main.c: In function `compare': main.c:160: warning: control reaches end of non-void function main.c: In function `decode': main.c:147: warning: control reaches end of non-void function main.c:67: warning: 'A' might be used uninitialized in this function main.c:67: warning: 'B' might be used uninitialized in this function main.c:67: warning: 'C' might be used uninitialized in this function main.c:67: warning: 'D' might be used uninitialized in this function main.c:67: warning: 'E' might be used uninitialized in this function main.c:67: warning: 'F' might be used uninitialized in this function main.c:67: warning: 'G' might be used uninitialized in this function main.c:67: warning: 'H' might be used uninitialized in this function main.c:67: warning: 'I' might be used uninitialized in this function main.c:67: warning: 'K' might be used uninitialized in this function main.c:67: warning: 'L' might be used uninitialized in this function main.c:67: warning: 'M' might be used uninitialized in this function main.c:67: warning: 'N' might be used uninitialized in this function main.c:67: warning: 'O' might be used uninitialized in this function main.c:67: warning: 'P' might be used uninitialized in this function main.c:67: warning: 'Q' might be used uninitialized in this function main.c:67: warning: 'R' might be used uninitialized in this function main.c:67: warning: 'S' might be used uninitialized in this function main.c:67: warning: 'T' might be used uninitialized in this function main.c:67: warning: 'V' might be used uninitialized in this function main.c:67: warning: 'U' might be used uninitialized in this function main.c:67: warning: 'W' might be used uninitialized in this function main.c:67: warning: 'Y' might be used uninitialized in this function main.c:67: warning: 'Z' might be used uninitialized in this function main.c:67: warning: 'X' might be used uninitialized in this function Linking console executable: console.exe Process terminated with status 0 (0 minutes, 5 seconds) 0 errors, 30 warnings
http://emmanuel-delahaye.developpez....tm#cfg_compilo
okk j'ai revise l problem que vous m'a vais dit ; mais ca marche pa encore ;
voila un simple inputet il doit etre comme ca apres compilation;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 3 HELL123567 WO1234591560158 PROGRAMMING 3712467 C123567123567156 AND MORE 371249 373579 278134573712467 45612356735792781245612467278
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 phrase 1: HELLO WORLD phrase 2: PROGRAMMING IS COOL phrase 3: AND MORE IF IN THIS CONTEXT
et voila mon programme apres qlq revisions; mercii d 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
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 #include<stdio.h> #include<ctype.h> #define MAX 10 int compare(int ledcode1[ ], int ledcode2[ ]); char decode(int ledcode[ ]); void clear(int ledcode[]); void array(int ledcode[]); int main(void){ char nextch; char current_ch, next_ch; int lines, counter=1,i ; int ch[10]; FILE *inp,*outp; inp= fopen ("input.txt", "r"); outp= fopen ("output.txt", "w"); fscanf(inp, "%d", &lines); nextch=getc(inp); while( counter<=lines){ fprintf(outp," \nPhrase %d: ", counter); nextch= getc(inp); while(nextch != EOF && nextch != '\n') { if(isdigit(nextch)!=0){ clear(ch); current_ch= nextch; next_ch= getc(inp); ch[current_ch-48]=1; while( current_ch < next_ch){ ch[next_ch-48]=1; current_ch=next_ch; next_ch=getc(inp); } array(ch); fprintf(outp,"%c", decode(ch)); } else if((isalpha(nextch)!=0) || (isspace(nextch)!=0) ) fprintf(outp,"%c", nextch); nextch= getc(inp);} counter++; } fclose(inp); fclose(outp); return(0); } char decode(int ledcode[ ]){ char A,B,C, D, E, F, G, H, I, J, K, L, M,N ,O, P, Q, R, S, T, V, U, W, Y, Z,X; int a[10]={0,1,1,1,1,1,0,1,0,0}; int b[10]={0,1,1,1,1,1,1,1,0,0}; int c[10]={0,0,0,0,1,1,1,0,0,0}; int d[10]={1,1,0,0,0,1,0,0,1,0}; int e[10]={0,1,1,0,1,1,1,0,0,0}; int f[10]={0,1,1,0,1,0,0,0,0,1}; int g[10]={0,1,1,0,0,1,1,0,0,1}; int h[10]={0,1,0,1,1,1,0,1,0,0}; int i[10]={0,0,0,1,0,0,0,1,0,0}; int j[10]={0,0,0,1,0,1,1,1,0,0}; int k[10]={0,1,0,1,1,1,0,0,0,1}; int l[10]={0,1,0,0,0,1,1,0,0,0}; int m[10]={0,1,1,1,0,1,0,1,0,0}; int n[10]={0,0,0,1,0,1,0,1,0,1}; int o[10]={0,1,1,1,0,1,1,1,0,0}; int p[10]={0,1,0,0,1,1,0,0,1,0}; int q[10]={0,1,1,1,1,0,0,1,0,0}; int r[10]={0,1,1,1,1,1,0,0,0,1}; int s[10]={0,1,1,0,1,0,1,1,0,0}; int t[10]={0,0,1,0,0,0,0,1,1,0}; int u[10]={0,1,0,1,0,1,1,1,0,0}; int v[10]={0,1,0,1,0,0,0,1,0,1}; int w[10]={1,1,0,1,0,1,0,1,0,1}; int x[10]={1,0,0,0,0,0,0,0,0,1}; int y[10]={0,1,0,1,1,0,0,1,0,0}; int z[10]={0,0,1,1,1,1,1,0,0,0}; if(compare(ledcode,a)==1) return('A'); else if ( compare(ledcode,b)==1) return('B'); else if (compare(ledcode,c)==1) return('C'); else if (compare(ledcode,d)==1) return('D'); else if ( compare(ledcode,e)==1) return('E'); else if (compare(ledcode,f)==1) return('F'); else if (compare(ledcode,g)==1) return('G'); else if ( compare(ledcode,h)==1) return('H'); else if (compare(ledcode,i)==1) return('I'); else if (compare(ledcode,j)==1) return('J'); else if ( compare(ledcode,k)==1) return('K'); else if (compare(ledcode,l)==1) return('L'); else if (compare(ledcode,m)==1) return('M'); else if ( compare(ledcode,n)==1) return('N'); else if (compare(ledcode,o)==1) return('O'); else if (compare(ledcode,p)==1) return('P'); else if ( compare(ledcode,q)==1) return('Q'); else if (compare(ledcode,r)==1) return('R'); else if (compare(ledcode,s)==1) return('S'); else if ( compare(ledcode,t)==1) return('T'); else if (compare(ledcode,u)==1) return('U'); else if (compare(ledcode,v)==1) return('V'); else if ( compare(ledcode,w)==1) return('W'); else if (compare(ledcode,x)==1) return('X'); else if (compare(ledcode,y)==1) return('Y'); else if (compare(ledcode,z)==1) return('Z'); } int compare(int ledcode1[ ], int ledcode2[ ]){ int i=0; while(ledcode1[i]==ledcode2[i]){ if(i==9) return(1); else i++; } return(0); } void clear(int ledcode[]){ int i; for(i=0;i<10;i++) ledcode[i]=0; } void array(int ledcode[]){ int i; for(i=0;i<10;i++) if(ledcode[i]!=1) ledcode[i]=0; }
euh....
je voudrais pas dire mais..... où lis-tu les lignes du fichier d'entrée stp ???![]()
Ensuite, le fait de déclarer char A, B, etc... ne fait que déclarer DES VARIABLES nommées A, B, etc.. En aucun cas les LETTRES A, B, etc..
Enfin, ta structure choisie pour ta fonction decode est horriblement compliquée pour ton problème, de même que ta fonction compare...
Sans m'occuper de ton main, la fonction decode est assez mal faite.
Il vaudrait mieux mettre tous les codes dans un même tableau Codes à double dimension, le premier sous-tableau contenant le code actuellement dans a[], le second celui de b[] et ainsi de suite. A ta place je terminerai par un code ({0,0,0,0,0,0,0,0,0,0} ?) indiquant que ledcode n'a pas été trouvé. Ceci ferait un tableau de 27 tableaux de 10 entiers.
Parallèlement, un tableau Lettres de 27 caractères contiendrait les caractères correspondant : 'A' en première position,... 'Z' en 26ieme et un caractère à choisir ( ' ' ?) en 27ieme.
L'indice du sous-tableau de Codes qui correspond à ledcode est également celui de la lettre qui lui correspond dans Lettres. ceci permet d'éliminer tous ces if else et éventuellement de compléter facilement la fonction avec d'autres caractères que les lettres.
mercii d'avoir repondu ;
mercii pr l'idee de table a 2 dimmensions ; mais l problem c que nous avons pa encore covere ca en classe ; alors on peut pa l'utilise ; pr les fonctions utilise ; c qu'il etait propose par le prof !
"où lis-tu les lignes du fichier d'entrée stp" jai pa vraiment compris !!![]()
mercii d m'aider.
[MOD : Le langage SMS est interdit. Merci d'éditer ton message pour rendre lisible, sous peine de suppression.]
Partager