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 67 68 69 70 71 72 73 74 75 76 77 78
| #include <stdio.h>
#include <stdlib.h>
#define v 4
#define h 5
void separateur(int n) {
int i;
for (i = 0; i < n; i++)
printf("*---",n);
puts("*");
}
void afficherTableu(int tableau[v][h])
{
int i, x;
for (i = 0; i < v; i++)
{
separateur(h);
for (x = 0; x < h; x++)
{
printf("|%3lf",tableau[i][x]);
}
puts("|");
}
separateur(h);
}
int main(void)
{
int tableau[v][h] = {{12.6, 13, 14, 15},
{21, 22.9, 23, 24},
{54, 88, 99.2, 47}};
int l, c, som,continuer;
do
{
for(l = 0; l < 3; l++)
{
som = 0;
for(c = 0; c < 4; c++)
{
printf("%2lf ",tableau[l][c]);
som += tableau[l][c];
}
printf("=%.1f\n",(double)som/4);
tableau[l][c] =som/4 ;
}
for( l = 0;l < 5 ;l++)
{
som = 0;
for( c = 0; c< 3 ;c++)
{
printf("%2d ", tableau[c][l]);
som+= tableau[c][l];
}
printf("=%.1f \n",(double)som/3);
tableau [c][l]= som/3;
}
afficherTableu(tableau);
printf("CONTUNUER ?(1=[OUI],AUTRE=[NON]\n");
scanf("%d",&continuer);
}while(continuer==1);
return 0;
} |
Partager