Ed232005 / CI-0112

0 stars 0 forks source link

Vector #1

Open Ed232005 opened 1 month ago

Ed232005 commented 1 month ago

public class mainclass{ public static void main(String[] args) { int[] array = {5, 10, 15}; Vector vector_a = new Vector(array); vector_a.im(array);

}

} ublic class Vector{ int[] vectorprop = new int[5]; public Vector(int[] vectorprop){ this.vectorprop=vectorprop; } public void setvectorprop(int[] vectorprop){ this.vectorprop=vectorprop; } public void im(int[] vectorprop){ for(int i=0; i<vectorprop.length; i++){ System.out.println(vectorprop[i]); } }

public void rand(){
  vectorprop[i] = (int)(Math.random()*100+1); 
}

}

Ed232005 commented 1 month ago

public void rand(int[] vectorprop){ for(int i=0; i<vectorprop.length; i++){ vectorprop[i]=(int)(Math.random()*100+1); System.out.println(vectorprop[i]); }

Ed232005 commented 1 month ago
public void ordenar(){
    for(int i= 0; i<vectorprop.length; i++){
      for(int o= 0; o<vectorprop.length; o++){
            if(vectorprop[i]>vectorprop[o]){
                int temporal=vectorprop[i];
                vectorprop[i]=vectorprop[o];
                vectorprop[o]=temporal;
            }
        }
    }
}

}