efrei/programmation-c-cpp/tp3/matrice-unitaire.c

25 lines
405 B
C
Raw Normal View History

2021-11-02 14:32:23 +01:00
/* 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;
}