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 79 80 81 82 83 84 85 86 87 88 89
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define max(a,b)((a)>(b)?(a):(b))
typedef int Matrice [100][100];
typedef int rempduree[100][100];
void remplir_matrice_duree(rempduree red)
{
int i,j,C[100];
Matrice m;
for(i=1;i<11;i++)
{ j=1;
while ((m[i][j]==0)&(j<=i))
{
j++;
}
C[i]=j;
}
for(j=1;j<11;j++)
{
for(i=j;i<11;i++)
if(C[i]<=j)
{
if (i>j)
{
red[i][j]=4*(j-max(C[i],C[j]))+2;
}
else
{
//if (i==j)
//red[j][j]==4*(j-C[j]);
//printf("%d\n",red[j][j]);
}
}
}
}
void ecrire(rempduree red)
{
int i,j;
for(j=1;j<11;j++)
{
for(i=j;i<11;i++)
printf("%d",red[i][j]);
printf("\n");
}
}
int duree (int i, int j)
{int a;
if(i>j)
{
a=rempduree[i][j];
return a;
}
else
if (i==j)
{
a=rempduree[j][j];
return a;
}
}
int main(void)
{
Matrice A;
int m, n;
rempduree redtab;
/* ouvrir le fichier Matrices.dta sur le disque réseau pour la lecture */
FILE * aLire = fopen("C......\\matrice.txt", "r") ;
if(aLire == NULL)
{
printf("Le fichier n'existe pas");
}
else
{ fscanf(aLire,"%d %d\n", &m, &n);
lire (aLire, A, m, n);
remplir_matrice_duree(redtab);
ecrire(redtab);
}
return 0;
} |
Partager