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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
fonction_for(int IDa,int j,int DF,int *tabID,int tab[MAX_AEROPORTS+1][MAX_AEROPORTS+1],pile **e, pile **d)
{
int k,K,y,z,dt=0;
for(k=1;k<=MAX_AEROPORTS;k++)
{
K=POtoID(k,tabID);
z=passe(K,*e); //si on est deja passé par l'id: retourne 1
if(z==1)
{
continue;
} else {
y=tab[j][k];
if (y==0)
{
continue;
} else {
if(y<=DF)
{
dt=(((*d)->valeur)+y);
printf("a. val. plus new:%d-->%d",y,dt);
ajouter(d,dt);
ajouter(e,K);
if(K==IDa)
{
printf("Nb d'elements esctp : %d\n",parcourir(*e));
printf("Nb d'elements dtot : %d\n",parcourir(*d));
// ICI C'EST UN "POINT DE FIN": JE VEUX FAIRE UN TEST POUR SAVOIR SI LE DERNIER ELEMENT
DE LA PILE EST PLUS PETIT QUE LE DERNIER ELEMENT DE L'ANCIENNE PILE.
SI OUI ALORS ON GARDE CETTE PILE LA.SI NON ON GARDE L'ANCIENNE.
C'EST FAISABLE ??
retirer(e);
retirer(d);
retirer(e);
retirer(d);
break;
} else {
int a;
a=parcourir(*e);
if(a<=10)
{
fonction_for(IDa,k,DF,tabID,tab,e,d); // modifs sur arguments
} else {
retirer(e);
retirer(e);
break;
}
}
} else {
//printf("\ny NUL:%d, et k:%d",y,k);
continue;
}
}
}
}
}
trajet(...)
{
...
D=IDtoPO(IDd,tabID,MAX_AEROPORTS);
A=IDtoPO(IDa,tabID,MAX_AEROPORTS);
DA=tab[D][A];
if(DA<=DF)
{
printf("trajet direct"); // ajouter modifs en consequence
} else {
for(j=1;j<=MAX_AEROPORTS;j++)
{
clear(&esctemp);
clear(&dtot);
ajouter(&esctemp,IDd);
i=IDtoPO(IDd,tabID,MAX_AEROPORTS);
x=tab[i][j];
if(x==0)
{
continue;
} else {
if(x<=DF)
{
ajouter(&dtot,x);
printf("\nDEB: ancienne valeur plus new:%d-->%d",x,dtot->valeur);
J=POtoID(j,tabID);
ajouter(&esctemp, J);
fonction_for(IDa,j,DF,tabID,tab,&esctemp,&dtot); // modifier dtot et esctemp
} else {
continue;
}
}
}
}
...
} |
Partager