1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include<stdlib.h>
#include <stdio.h>
#define DimLigne 2
#define DimColonne 2
void LigneEtoile() /* Ligne d'etoiles */
{
int i;
printf("\n");
for (i = 0; i < 15; i++)
{
printf("*");
}
printf("\n");
printf("\n");
}
void AfficheTableau2d(int *Tab[][]) /* Procédure d'affiche d'un tableau à 2 dimensions */
{
int x, y;
for(x = 0; x < DimLigne; x++)
{
for(y = 0; y < DimColonne; y++)
{
printf("Tab[%d][%d]=%d", x, y, Tab[x][y]);
printf("\n");
}
}
}
int main ()
{
/* Remplissage du tableau à 2 dimensions */
int tab[DimLigne][DimColonne];
for(int x = 0; x < DimLigne; x++)
{
for(int y = 0; y < DimColonne; y++)
{
printf ("Saisir tab[%d][%d] : ", x, y);
scanf("%d", &tab[x][y]);
}
}
LigneEtoile();
/* Affichage du tableau à 2 dimensions saisi avant */
for(int y = 0; y < DimLigne; y++)
{
for(int x = 0; x < DimColonne; x++)
{
printf("tab[%d][%d]=%d", y, x, tab[y][x]);
printf("\n");
}
}
LigneEtoile();
AfficheTableau2d(tab);
return 0;
} |
Partager