Add addition matricielle
This commit is contained in:
parent
d1e8c0e3db
commit
560ef65d1e
2 changed files with 39 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -26,3 +26,4 @@ affichage-tableaux
|
|||
min-max-moy
|
||||
lettre-perdue
|
||||
matrice-unitaire
|
||||
addition-matricielle
|
||||
|
|
38
programmation-c-cpp/tp3/addition-matricielle.c
Normal file
38
programmation-c-cpp/tp3/addition-matricielle.c
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue