exo1 tp5 (langage C) [RESOLU]
Page 1 sur 1
exo1 tp5 (langage C) [RESOLU]
Question 1.1 :
Declarer un tableau tab_alph de 26 caractères et l'initialiser avec l'alphabet minuscule dans le desordre.
Apparemment il y a une erreur à la ligne 3 à cause d'une parenthèse (j'ai essayé avec void) , si quelqun a une idee...
1 #include<stdio.h>
2 #include<math.h>
3 int main(){
4 int taille = 26;
5 char tab_alph[26] = {'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'w', 'x', 'c', 'v', 'b', 'n'};
6 int i;
7 for(i=0 ; i<taille ;i++){
8 return(tab_alph[i]);}
9 printf("%c", tab_alph[i]);
10 return(0);
11 }
Declarer un tableau tab_alph de 26 caractères et l'initialiser avec l'alphabet minuscule dans le desordre.
Apparemment il y a une erreur à la ligne 3 à cause d'une parenthèse (j'ai essayé avec void) , si quelqun a une idee...
1 #include<stdio.h>
2 #include<math.h>
3 int main(){
4 int taille = 26;
5 char tab_alph[26] = {'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'w', 'x', 'c', 'v', 'b', 'n'};
6 int i;
7 for(i=0 ; i<taille ;i++){
8 return(tab_alph[i]);}
9 printf("%c", tab_alph[i]);
10 return(0);
11 }
Dernière édition par Maxime.L le Lun 20 Déc - 23:03, édité 1 fois
Invité- Invité
Re: exo1 tp5 (langage C) [RESOLU]
Je comprends pas le but du for. Il sert à afficher ?
Je l'ai fait hier et ça donnait plutôt :
#include<stdio.h>
#include<math.h>
int main(){
int taille = 26;
char tab_alph[26] = {'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'w', 'x', 'c', 'v', 'b', 'n'};
int i;
for(i=0 ; i<taille ;i++){
printf ("%c",tab_alpha[i]);
}
return(0);
}
Testé et ça fonctionne
Je l'ai fait hier et ça donnait plutôt :
#include<stdio.h>
#include<math.h>
int main(){
int taille = 26;
char tab_alph[26] = {'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'w', 'x', 'c', 'v', 'b', 'n'};
int i;
for(i=0 ; i<taille ;i++){
printf ("%c",tab_alpha[i]);
}
return(0);
}
Testé et ça fonctionne
Christophe- Membre actif
- Messages : 195
Date d'inscription : 04/12/2010
Re: exo1 tp5 (langage C) [RESOLU]
ok merci pour la correction, et bien la boucle for était pour créer le tableaux sauf que je comptai afficher un à un puisque rien était préciser dans la consigne?
Invité- Invité
Re: exo1 tp5 (langage C) [RESOLU]
quand tu dis un par un, c'est un par ligne ? ou un, puis il disparaît, le suivant etc etc ?
Mais pour la création du tableau c'était :
char tab_alph[26] = {'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'w', 'x', 'c', 'v', 'b', 'n'};
à partir de là le tableau est créé et remplit ^^
Mais pour la création du tableau c'était :
char tab_alph[26] = {'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'w', 'x', 'c', 'v', 'b', 'n'};
à partir de là le tableau est créé et remplit ^^
Christophe- Membre actif
- Messages : 195
Date d'inscription : 04/12/2010
Re: exo1 tp5 (langage C) [RESOLU]
un, puis il disparait...
oui enfin je voulais dire son affichage ^^
oui enfin je voulais dire son affichage ^^
Invité- Invité
Re: exo1 tp5 (langage C) [RESOLU]
Bah là faut utiliser curses non ? ^^ si non ça réinitialise pas l'affichage de la fenetre.
Christophe- Membre actif
- Messages : 195
Date d'inscription : 04/12/2010
Re: exo1 tp5 (langage C) [RESOLU]
autant pour moi je me limiterai a ce que tu as fait pour le moment (je suis un peu paumé en prog )
Invité- Invité
Re: exo1 tp5 (langage C) [RESOLU]
T'inquiètes pas tu es pas le seul...
Christophe- Membre actif
- Messages : 195
Date d'inscription : 04/12/2010
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|