5 réponses
salut,
je l'ai fait en pascal
for i=1 to n do
for j=1 to m do
C[i,j]=A[i,j]+B[i,j]
à vous de faire la transformation au C++
Bonne chance.
Merci
je l'ai fait en pascal
for i=1 to n do
for j=1 to m do
C[i,j]=A[i,j]+B[i,j]
à vous de faire la transformation au C++
Bonne chance.
Merci
j'ai pas testé, je te fais ca vite fait mais c'est dans l'idée.
matrice.h #ifndef MATRICE #define MATRICE typedef struct _matrice * matrice; matrice new_matrice(unsigned int nb_l,unsigned int nb_c); void delete_matrice(matrice m); inline double get_value(matrice m,unsigned int ligne,unsigned int colonne); inline void set_value(matrice m,unsigned int ligne,unsigned int colonne,double val); //... Rajouter les autres fonctions de matrice.c #endif matrice.c #include <stdlib.h> #include <stdio.h> struct _matrice{ unsigned int nb_ligne; unsigned int nb_colonne; double **data; }; struct _matrice * new_matrice(unsigned int nb_l,unsigned int nb_c){ struct matrice m=(struct _matrice *)malloc(sizeof(struct _matrice)); unsigned int i; m.nb_ligne=nb_l; m.nb_colonne=nb_c; m.data=(double **)malloc(sizeof(double *)*nb_ligne); for(i=0;i<nb_ligne;++i){ m.data=(double *)calloc(sizeof(double),nb_colonne); } return m; } void delete_matrice(struct _matrice *m){ unsigned int i; for(i=0;i<nb_ligne;++i){ free(m.data[i]); } free(m.data); } inline double get_value(struct _matrice const *m,unsigned int ligne,unsigned int colonne){ return m.data[ligne][colonne]; } inline void set_value(struct _matrice const *m,unsigned int ligne,unsigned int colonne,double val){ m.data[ligne][colonne]=val; } inline unsigned int get_nb_ligne(struct _matrice const *m){ return m.nb_ligne; } inline unsigned int get_nb_colonne(struct _matrice const *m){ return m.nb_colonne; } void show_matrice(struct _matrice const * m){ unsigned int i,j; for(i=0;i<get_nb_ligne(m);++i){ for(j=0;j<get_nb_colonne(m);++j){ printf("%lf\t"); } printf("\n"); } } struct _matrice * add_matrice(struct _matrice const *a,struct _matrice const *b){ unsigned int i,j; struct _matrice *c; if (get_nb_ligne(a)!=get_nb_ligne(b) || (get_nb_colonne(a)!=get_nb_colonne(b)){ return NULL; } c=new_matrice(get_nb_ligne(a),get_nb_colonne(a)); for(i=0;i<get_nb_ligne(m);++i){ for(j=0;j<get_nb_colonne(m);++j){ //pour la multiplication externe changer + par * dans la ligne ci dessous :p set_value(c,i,j, ( get_value(a,i,j) + get_value(b,i,j) ) ); } } return c; } main.c #include "matrice.h" int main(){ matrice a,b,c; a=new_matrice(5,6); b=new_matrice(5,6); //.... matrice c=add_matrice(a,b); show_matrice(c); //... delete_matrice(a); delete_matrice(b); delete_matrice(c); return 0; }
salut je remercie pour votre soutien si precieux alors soit plus clair au niveau du traitement mais c'est surtout une somme de deux matrice..
merci et j'attend une fois de plus votre reponse!!!
merci et j'attend une fois de plus votre reponse!!!
Arghh, je rêve ????
Il te fait un super code où il te fuffit de trouver l'endroit où se trouve l'addition et toi tu voudrais qu'il soit plus clair ? Dis moi que j'hallucine !
PS : tu t'es éclaté, mamiemambo, sur ce coup-là !
m.
Il te fait un super code où il te fuffit de trouver l'endroit où se trouve l'addition et toi tu voudrais qu'il soit plus clair ? Dis moi que j'hallucine !
PS : tu t'es éclaté, mamiemambo, sur ce coup-là !
m.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question