Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void muestraRepetidos(int array[]) {
- int cuentaPosición = 0;
- ArrayList<Integer> valor = new ArrayList<Integer>();
- ArrayList<ArrayList<Integer>> posición = new ArrayList<ArrayList<Integer>>();
- for (int i = 0; i < array.length - 1; i++) {
- if (!valor.contains(array[i])) {
- valor.add(array[i]);
- posición.add(new ArrayList<Integer>());
- }
- }
- for (int j = 0; j < array.length - 1; j++) {
- for (int k = j + 1; k < array.length; k++) {
- if (array[j] == array[k]) {
- System.out.println("Posición: " + j);
- posición.get(j).add(k);
- } else {
- break;
- }
- }
- }
- System.out.println(valor);
- System.out.println("Tamaño lista valor " + valor.size() + " y lista posición " + posición.size());
- for (int par = 0; par < valor.size(); par++) {
- System.out.println("A " + valor.get(par) + " P " + posición.get(par));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement