Add matrice unitaire
This commit is contained in:
parent
0f3fa8d027
commit
d1e8c0e3db
2 changed files with 25 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -25,3 +25,4 @@ calculatrice
|
|||
affichage-tableaux
|
||||
min-max-moy
|
||||
lettre-perdue
|
||||
matrice-unitaire
|
||||
|
|
24
programmation-c-cpp/tp3/matrice-unitaire.c
Normal file
24
programmation-c-cpp/tp3/matrice-unitaire.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* Matrice unitaire */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define DIMENSION 4
|
||||
|
||||
|
||||
int main() {
|
||||
int matrice[DIMENSION][DIMENSION];
|
||||
|
||||
for (int i = 0; i < DIMENSION; i++) {
|
||||
for (int j = 0; j < DIMENSION; j++) {
|
||||
if (i == j) matrice[i][j] = 1;
|
||||
else matrice[i][j] = 0;
|
||||
printf("%d ", matrice[i][j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue