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
|
import java.lang.Object;
import java.util.*;
public class tableau
{
private int [] nombre = {5, 3, 2, 4, 1};
void tri_Inser()
{
int i, j, v;
for (i=0; i<nombre.length ; i++)
{
j=i-1;
v = nombre[i];
while(j>0 && nombre[j]>v)
{
nombre[j+1] = nombre[j];
j=j+1;
}
nombre[j+1] = v;
}
}
void afficher()
{
//return.... ;
}
public static void main (String[] args)
//appel de la methode tri_insert() et afficher()
// affichage du tableau
{
tableau table = new tableau();
table.tri_Inser();
table.afficher();
}
} |
Partager