Besoin d'aide urgent SVP

cs_paulina82 Messages postés 19 Date d'inscription vendredi 3 juin 2005 Statut Membre Dernière intervention 27 avril 2008 - 3 avril 2006 à 13:46
cs_satellite34 Messages postés 688 Date d'inscription mercredi 6 avril 2005 Statut Membre Dernière intervention 2 juin 2006 - 3 avril 2006 à 23:31
Bonjour,
j'ai un gros probleme avec mon programme ecri en langage C.lorsque je complile il n'afiche pa d'erreur mais lorsque j'esaye de l'executé il veut pas.Si quelqu'un pourais m'aidé je seré trés reconesante car c pour un projet.
Si ou moin qq'1 sais qu'est ce qui pouré clocher. je vous remerci d'avance.
le programme est le suivant :

#include <stdio.h>
#define N 5
#define M 5




void affiche (char tab_test[N][M],int lig,int col){
int i , j;

for(i=0;i<lig;i++){
for(j=0;j<col;j++){
printf("%c ",tab_test[i][j]);
}
}
printf("\n");
}




void affiche2 (int tab_test[N][M],int lig,int col){
int i , j;

for(i=0;i<lig;i++){
for(j=0;j<col;j++){
printf("%c ",tab_test[i][j]);
}
}
printf("\n");
}



void init_tab ( char tab[N][M],int lig,int col,char car){


int i,j;
int k,l;


for(i=0;i<lig;i++){
for(j=0;j<col;j++){
tab[i][j]=car;

}
}
//affiche(tab,i,j);
}


void init_tab2 ( int tab[N][M],int lig,int col,int car){


int i,j;
int k,l;


for(i=0;i<lig;i++){
for(j=0;j<col;j++){
tab[i][j]=car;

}
}
//affiche(tab,i,j);
}


void nb_occurences(char image[N][M],int lig,int col){

char tablo[N][M];
int tb_occ[N][M];

int i,j;
int ligne=0;
int k;


init_tab(tablo,N,3,'\0');
init_tab2(tb_occ,N,1,0);

for(i=0;i<lig;i++){
for(j=0;j<col;j++){

for(k=0;k<3;k++){

if(image[i][j]==tablo[k][1] ){






tb_occ[k][1] ++;
}
else {
tb_occ[ligne][1] ++;
tablo[ligne][1]=image[i][j];
ligne ++;
}
}
}
}
affiche(tablo,5,3);
affiche2(tb_occ,5,1);
}



int main(){

char tab[N][M];
char tab_test[N][M]={{'a','b'},{'c','d'}};
char image[N][M]={{'a','b','c','d','e'} , {'a','a','c','d','e'},{'b','b','c','a','e'},{'a','b','c','d','e'},{'a','b','c','d','e'}};

//6 a 5 b 5 c 4 d 5 e

affiche(tab_test,2,2);
init_tab(tab,3,3,'b');
init_tab(tab,N,4,'\0');

nb_occurences(image ,5,5);


return 0;
}

4 réponses

cs_satellite34 Messages postés 688 Date d'inscription mercredi 6 avril 2005 Statut Membre Dernière intervention 2 juin 2006 1
3 avril 2006 à 13:50
system("pause");

avant return 0;



@+;
satellite34

http://www.rootscommunity.com/</FON< body>
0
wxccxw Messages postés 755 Date d'inscription samedi 15 mai 2004 Statut Membre Dernière intervention 30 janvier 2011
3 avril 2006 à 17:17
ben oui sinon ton programme s'eteint :)

ps : si tu est en C utilise plutot :



#include <conio.h>



et avant return 0; tu ajoute getch();

mieux que system("pause"); car il n'affiche pas de message :)

voila :)
0
SAKingdom Messages postés 3212 Date d'inscription lundi 7 novembre 2005 Statut Membre Dernière intervention 16 février 2009 15
3 avril 2006 à 20:01
Ben c peut-être mieu qui ai du texte sinon l'utilisateur peut croire que le programme est planté.

___________________________________________
Les plus grands esprits trouvent toujours une solution
0
cs_satellite34 Messages postés 688 Date d'inscription mercredi 6 avril 2005 Statut Membre Dernière intervention 2 juin 2006 1
3 avril 2006 à 23:31
voila le code qui a résolu le probléme, pour la communauté:


// rien.cpp : Defines the entry point for the console application.


#include



#include






#define N 5


#define M 5


void affichertablo(
char tablo[N][M] )


{


printf(
"affichage d' un tableau de %d lignes et de %d colonnes\n", N, M);



for(
int j = 0; j < N; j++)


{



for(
int i = 0; i < N; i++)


{


printf(
"%c ", tablo[j][i]);
// affiche le tablo


}


printf(
"\n");


}


}


void nb_occurences(
char image[N][M],
char c )


{



int nb = 0;



int x = 0;



for(
int j = 0; j < N; j++ )


{



for(
int i = 0; i < N; i++ )


{



//printf("%c ", image[j][i]); // affiche le tablo



if( c == image[j][i] )
// vérifie le nombre de c ds le tablo


nb++;


}


}


printf(
"nd occ de %c : %d\n", c, nb);


}








int main()
// ici, les arguments de ton soft


{



char tab_test[N][M]={{
'a',
'b'},{
'c',
'd'}};



char image[N][M]={{
'a',
'b',
'c',
'd',
'e'} , {
'a',
'a',
'c',
'd',
'e'},{
'b',
'b',
'c',
'a',
'e'},{
'a',
'b',
'c',
'd',
'e'},{
'a',
'b',
'c',
'd',
'e'}};





char occ[N] = {
'a',
'b',
'c',
'd',
'e'};
// tablo des caracteres qu'on veut trouver ds image[][]


// ce que je ferai a ta place c'est de passer ce tableau en parametre du programme


// com'ca tu pourrai, au lancement du soft choisir les char a rechercher ds le tableau


affichertablo(image);


printf(
"recherche des occurences\n");



for(
int i = 0; i < N; i++)


{


nb_occurences(image, occ[i]);


}


system(
"PAUSE");



return 0;


}


merci moi, hihihi
@+;
satellite34

http://www.rootscommunity.com/http://rootscommunity.free.fr
0
Rejoignez-nous