Matrices carrées
Fermé
infobens
Messages postés
33
Date d'inscription
jeudi 10 juin 2004
Statut
Membre
Dernière intervention
3 mai 2007
-
17 juil. 2005 à 14:50
mamiemando Messages postés 33079 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 23 avril 2024 - 25 juil. 2005 à 00:21
mamiemando Messages postés 33079 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 23 avril 2024 - 25 juil. 2005 à 00:21
A voir également:
- Matrices carrées
- On dispose cote a cote des petites tables carrées - Forum Programmation
- Produit de deux matrices carrées ✓ - Forum Programmation
- Le produit de 2 matrices carrées - Forum Programmation
- Parenthèses carrées ✓ - Forum MacOS
- Comment mettre une requête préparée entre parenthèses ✓ - Forum PHP
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
mamiemando
Messages postés
33079
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
23 avril 2024
7 749
18 juil. 2005 à 01:02
18 juil. 2005 à 01:02
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; }
infobens
Messages postés
33
Date d'inscription
jeudi 10 juin 2004
Statut
Membre
Dernière intervention
3 mai 2007
22 juil. 2005 à 15:58
22 juil. 2005 à 15:58
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!!!
grofwa
Messages postés
440
Date d'inscription
jeudi 24 juillet 2003
Statut
Membre
Dernière intervention
21 juillet 2006
479
22 juil. 2005 à 16:05
22 juil. 2005 à 16:05
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
mamiemando
Messages postés
33079
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
23 avril 2024
7 749
25 juil. 2005 à 00:21
25 juil. 2005 à 00:21
Ouais ca m'a distrait ;o) Bon je t'aide la fonction s'appelle add_matrice... Je peux pas faire plus ;)