Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- /*
- *
- * @author Hantack
- */
- public class PracticaArrays {
- public static void main(String[] args) {
- ArrayList<Integer> lista = new ArrayList<Integer>();
- Scanner xr = new Scanner(System.in);
- int cont = 0;
- System.out.println("Que número entre 1 y 30 deseas buscar? ");
- int buscar = xr.nextInt();
- for (int i = 0; i < 2000; i++) {
- int elemento = (int)(Math.random()*30);
- lista.add(elemento);
- if(elemento == buscar){
- cont++;
- }
- }
- System.out.println("Se encontró el "+buscar+" "+cont+" veces");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement