Add addition matricielle

This commit is contained in:
flyingscorpio@pinebookpro 2021-11-02 14:46:30 +01:00
parent d1e8c0e3db
commit 560ef65d1e
2 changed files with 39 additions and 0 deletions

1
.gitignore vendored
View file

@ -26,3 +26,4 @@ affichage-tableaux
min-max-moy
lettre-perdue
matrice-unitaire
addition-matricielle

View file

@ -0,0 +1,38 @@
/* Addition matricielle */
#include <stdio.h>
#include <stdlib.h>
#define COLONNES 2
#define LIGNES 3
int main() {
int matrice_gauche[LIGNES][COLONNES];
int matrice_droite[LIGNES][COLONNES];
int matrice_addition[LIGNES][COLONNES];
matrice_gauche[0][0] = 1;
matrice_gauche[0][1] = 3;
matrice_gauche[1][0] = 1;
matrice_gauche[1][1] = 0;
matrice_gauche[2][0] = 1;
matrice_gauche[2][1] = 2;
matrice_droite[0][0] = 0;
matrice_droite[0][1] = 0;
matrice_droite[1][0] = 7;
matrice_droite[1][1] = 5;
matrice_droite[2][0] = 2;
matrice_droite[2][1] = 1;
for (int lgn = 0; lgn < LIGNES; lgn++) {
for (int col = 0; col < COLONNES; col++) {
matrice_addition[lgn][col] = matrice_gauche[lgn][col] + matrice_droite[lgn][col];
printf("%d ", matrice_addition[lgn][col]);
}
printf("\n");
}
return 0;
}