Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class ListadoNumeros {
- private int[] numeros;
- public ListadoNumeros(){
- numeros=new int[100];
- }
- public void Llenar(){
- Random rand=new Random();
- for(int i=0;i<numeros.length;i++){
- numeros[i]=rand.nextInt(100)+1;
- }
- }
- public void mostrar(){
- for(int i=0;i<numeros.length;i++){
- System.out.println(numeros[i]+" ");
- }
- System.out.println( );
- }
- public void ordenar(boolean tipo){
- int aux=0;
- if(tipo==true){
- for(int i=0;i<numeros.length-1;i++){
- for(int j=0;j<numeros.length;j++){
- if(numeros[i]<numeros[j]){
- aux=numeros[j];
- numeros[j]=numeros[j+1];
- numeros[j+1]=aux;
- }else{
- }
- }
- }
- }
- }
- public void menorMayor(){
- int aux;
- for(int i=0;i<numeros.length-1;i++){
- for(int j=i+1;j<numeros.length;j++){
- if(numeros[i]>numeros[j]){
- aux=numeros[j];
- numeros[j]=numeros[j+1];
- numeros[j+1]=aux;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment