1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public static void main(String[] args)
{
String[] ensemble = { "A", "B", "C", "D" };
int profondeur = 10;
displayEnsemble(ensemble, profondeur, 0, "", 0);
}
public static void displayEnsemble(String[] ensemble, int profMax,
int profCourante, String prefix, int rang)
{
if (profCourante < profMax)
{
for (int i = rang; i < ensemble.length; i++)
{
System.out.println(prefix + ensemble[i]);
}
for (int i = rang; i < ensemble.length; i++)
{
displayEnsemble(ensemble, profMax, profCourante + 1, prefix
+ ensemble[i], i + 1);
}
}
} |
Partager