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
|
void Rec_RechercheChemin(int *Proposition, int **Enonce, int *Solution, int indiceDebut, int indiceProposition, int *nombredeSolution,int *nombreMax)
{
int i,j;
int nombre = 0;
if (indiceDebut < 7)
{
for (i = indiceDebut ; i < 7 ; i++)
if (indiceProposition == 0)
{
Proposition[0] = i;
Rec_RechercheChemin(Proposition, Enonce, Solution, i + 1, 1, &(*nombredeSolution), &(*nombreMax));
}
else
if (Enonce[Proposition[indiceProposition-1]][1] <= Enonce[i][0])
{
Proposition[indiceProposition] = i;
Rec_RechercheChemin(Proposition, Enonce, Solution, i + 1, indiceProposition + 1, &(*nombredeSolution), &(*nombreMax));
}
/* On recupere le nombre d'element triée de la proposition trouvé */
for (j=0 ; j<7 ; j++)
if (Proposition[j] != -1)
nombre++;
// On compare et agit
if((*nombreMax) <= nombre)
{
if((*nombreMax) == nombre)
{
(*nombredeSolution)++;
realloc (Solution, sizeof(int) * 7 * (*nombredeSolution));
}
else
{
(*nombredeSolution) = 1;
free(Solution);
Solution = (int*) malloc (sizeof(int) * 7);
}
(*nombreMax) = nombre;
for (j=0 ; j<7 ; j++)
Solution[j + ((*nombredeSolution)-1)*7] = Proposition[j];
}
// On MAJ Proposition
Proposition[indiceProposition] = -1;
}
else
if (indiceProposition == 0)
/* Cas tres particulier : le tableau est strictement decroissant*/
if ((*nombredeSolution) == 6)
{
(*nombredeSolution)++;
realloc (Solution, sizeof(int) * 7 * (*nombredeSolution));
Solution[7 * ((*nombredeSolution)-1)] = 6;
for (i=1 ; i<7 ; i++)
Solution[7 * ((*nombredeSolution)-1)+i] = -1;
}
} |
Partager