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 111 112 113 114 115 116
|
int solution_initiale[][] = {{2,1,1,12,0},{1,1,2,8,0},{1,2,2,2,8},{3,1,3,12,0},{3,2,3,12,12},{1,3,2,6,10}, {3,3,1,12,24}, {2,2,3,11,24},{2,3,3,10,35}};
int date_debut;
boolean test = true;
ArrayList<ArrayList<int []>> chemin_critique = new ArrayList<ArrayList<int []>>();
boolean cout = true;
while (k<nbre_oper)
{int t =0;
int tab_temp[]= new int[5];
if (solution_initiale[k][4]== 0)
{
for ( t=0; t<5;t++)
{
tab_temp[t]= solution_initiale[k][t];
}
ArrayList<int[]> temp_princ = new ArrayList<int []>();
temp_princ.add(tab_temp) ;
chemin_critique.add(temp_princ);
taille = chemin_critique.size();
}
k++;
}
int tab[] = new int[5];
for (i=0; i<taille; i++)
{
ArrayList<int[]> temp2 = chemin_critique.get(i);
for (j=0; j< temp2.size(); j++)
{
tab = chemin_critique.get(i).get(j);
date_debut = tab[3]+ tab[4];
if ( date_debut > 45)
{
cout = false;
System.out.println("date de debu = 45 pour uen fois");
}
else cout = true;
k=0;
while (k<9 && cout)
{
if (solution_initiale[k][4] == date_debut && test )
{
int tab_temp[]= new int[5];
int t=0;
for ( t=0; t<5;t++)
{
tab_temp[t]= solution_initiale[k][t];
}
temp2.add(tab_temp) ;
test = false;
k++;
}
else if (solution_initiale[k][4] == date_debut && test== false )
{
int tab_temp[]= new int[5];
int t=0;
for ( t=0; t<5;t++)
{
tab_temp[t]= solution_initiale[k][t];
}
ArrayList<int[]> temp_second = new ArrayList<int []>();
temp_second = new ArrayList<int []>(temp2) ;
temp_second.set(temp2.size() -1, tab_temp) ;
chemin_critique.add(temp_second);
k++;
}
else k++;
}
test = true;
cout = true;
}
}
// l' afiichage
taille = chemin_critique.size();
int m =1;
for (i=0; i<taille; i++) {
System.out.println ("chemin"+m+" : ");
ArrayList<?> temp2 = chemin_critique.get(i);
for (j=0; j< temp2.size(); j++) {
tab = chemin_critique.get(i).get(j);
System.out.print(Arrays.toString(tab));
}
System.out.println("\n");
m++;
} |
Partager