public class Ordenamiento extends ArregloUni
{
public void baraja()
{
int i,j,aux;
for(i=1;i<=n-1;i++)
{
aux=a[i];
j=i-1;
while(a[j]>aux && j>0)
{
a[j+1]=a[j];
j--;
}
if(a[j]>aux)
{
a[j+1]=a[j];
a[j]=aux;
}
else
a[j+1]=aux;
}
}
public void baraja2()
{
int i,j,aux;
for(i=1;i<=n-1;i++)
{
aux=a[i];
j=i-1;
while(a[j]<aux && j>0)
{
a[j+1]=a[j];
j--;
}
if(a[j]<aux)
{
a[j+1]=a[j];
a[j]=aux;
}
else
a[j+1]=aux;
}
}
}
No hay comentarios:
Publicar un comentario