43 lines
1.5 KiB
Java
43 lines
1.5 KiB
Java
|
public class Main{
|
||
|
public static void main(String[] args){
|
||
|
int[] tableauEntier = new int[args.length];
|
||
|
int i;
|
||
|
try{
|
||
|
//convertion en int
|
||
|
for (i=0; i<args.length; i++){
|
||
|
tableauEntier[i] = Integer.parseInt(args[i]);
|
||
|
if (tableauEntier[i] < 0){
|
||
|
throw new NumberFormatException("Erreur : l'entier naturel saisis est negatif "+tableauEntier[i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//remplissage
|
||
|
File<Integer> fileRemplisBulle = new File<>();
|
||
|
File<Integer> fileRemplisTri = new File<>();
|
||
|
File<Integer> fileVide = new File<>();
|
||
|
for (int entier : tableauEntier){
|
||
|
fileRemplisBulle.enqueue(entier);
|
||
|
fileRemplisTri.enqueue(entier);
|
||
|
}
|
||
|
|
||
|
// methode bulle
|
||
|
Bulle.bulle(fileRemplisBulle, fileVide);
|
||
|
System.out.print("Bulle : ");
|
||
|
while (fileVide.isEmpty() == false){
|
||
|
System.out.print(fileVide.dequeue() + " ");
|
||
|
}
|
||
|
System.out.println();
|
||
|
|
||
|
//methode tri
|
||
|
Bulle.tri(fileRemplisTri);
|
||
|
System.out.print("Tri : ");
|
||
|
while (fileRemplisTri.isEmpty() == false){
|
||
|
System.out.print(fileRemplisTri.dequeue() + " ");
|
||
|
}
|
||
|
System.out.println();
|
||
|
}
|
||
|
catch(NumberFormatException e){
|
||
|
System.out.println("argument invalide");
|
||
|
}
|
||
|
}
|
||
|
}
|