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
| Visage* Lecture(char* s_chemin, int* tab_i_priorite, int* p_i_nbvisage)
{
int i_nbCaracteristiques, i, j;
char c_temp;
int* tab_i_temp[6]; ///tableau pour stocker temporairement le visage lu
int* tab_i_mins[6]; ///tableau qui contient les minima de chaque colonne
int* tab_i_maxs[6]; ///tableau qui contient les maxima de chaque colonne
Visage* tab_visage;
FILE* p_fichier = fopen(s_chemin, "a");
fscanf("%d\n%d\n", &(*p_i_nbvisage), &i_nbCaracteristiques); /// lit les deux premieres ligne pour savoir combien de visage
///et combien de caracteristiques nous avons dans le fichier
tab_visage = (Visage*)malloc((*p_i_nbvisage)*sizeof(Visage));
/// on initialise les tableaux avec le premier visage
for (j = 0; j < i_nbCaracteristiques; j++)
{
fscanf("%d", &tab_i_temp[j]);
tab_i_maxs[j] = tab_i_temp[j];
tab_i_mins[j] = tab_i_temp[j];
fscanf("%c",&c_temp);
}
//donne de bonne valeurs a tab_i_priorite
fscanf("%c",&c_temp);
tab_visage[0]=NouveauVisage(tab_i_priorite, tab_i_temp,i_nbCaracteristiques);
for (i = 1 ; i< (*p_i_nbvisage); i++)
{
for (j = 0; j < i_nbCaracteristiques; j++)
{
fscanf("%d", &tab_i_temp[j]);
if (tab_i_temp[j] > tab_i_maxs[j])
tab_i_maxs[j]= tab_i_temp[j];
if (tab_i_temp[j] < tab_i_mins[j])
tab_i_mins[j] = tab_i_temp[j];
fscanf("%c",&c_temp);
}
fscanf("%c",&c_temp);
tab_visage[i]=NouveauVisage(tab_i_priorite, tab_i_temp,i_nbCaracteristiques);
}
return tab_visage;
} |
Partager