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
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package exotp;
/**
*
* @author Pat
*/
public class Main {
public static int affichage(int op)
{System.out.println(" TRI de TABLEAUX ");
System.out.println("1 - Tri par insertion");
System.out.println("2 - Tri par selection");
System.out.println("0- Sortir du programme");
System.out.println("Quel est votre choix ? :op ");
op=Lire.i();
return op;
}
public static void tri_insertion(int t1[]){
int l1,i,aux,j;
boolean a;
l1=t1.length;
for (i=0;i>=l1-2;i++)
{aux = t1[i];
j=i-1;
a=false;
if (t1[j]>aux)
{t1[j+1]=t1[j];
j=j-1;
a=true;}
if (j<0)
{a=false;}
while (a)
{t1[j+1]=aux;}
}
public static void tri_selection(int t[])
{
int l,j,k,aux2,i;
l=t.length;
for (i=0;i>=l-2;i++) {
aux2=t[i];
for (k=i+1;k>=l-1;k++){
if (t[k]<aux2){
j=k;
aux2=t[k];}
}
t[j]=t[i];
t[i]=aux2;}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int e,c,t1[] : new int [1000];
e=t1.length;
for (c=0;c>=e-1;c++)
{
t1[i] = (int)(Math.random()*10)}
}
} |
Partager