52 lines
834 B
C
52 lines
834 B
C
#include <stdio.h>
|
|
|
|
#define N 3
|
|
|
|
int main () {
|
|
|
|
|
|
// int A[N][N] = {1,2,3,4,5,6,7,8,9}; // Initialisation pas magique
|
|
int A[N][N] = {4,2,3,2,3,4,3,4,2}; // Initialisation pas magique
|
|
int B[N][N] = {0};
|
|
void affiche (int, int tab[N][N]);
|
|
void matrice_echange(int, int tab[N][N], int tab2[N][N]);
|
|
|
|
affiche(N,B);
|
|
matrice_echange(N,A,B);
|
|
affiche(N,A);
|
|
affiche(N,B);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
void matrice_echange(int n, int orig[n][n], int target[n][n])
|
|
{
|
|
int i;
|
|
int j;
|
|
for(i=0;i<n;i=i+1)
|
|
{
|
|
for(j=0;j<n;j++)
|
|
{
|
|
target[i][j] = orig[i][j];
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
void affiche(int n, int tab[n][n]) { // affiche les 4 elements
|
|
int i;
|
|
int j;
|
|
for(i=0;i<n;i=i+1)
|
|
{
|
|
for(j=0;j<n;j++)
|
|
{
|
|
printf("%d\t",tab[i][j]);
|
|
}
|
|
printf("\n"); // pour sauter de ligne
|
|
}
|
|
return;
|
|
}
|