//Codificado por Beastieux
public class SyGContarElementosRepetidos {
static int A = 10;
static int B = 20;
static int vectorA[] = new int[A];
static int vectorB[] = new int[B];
static int elemA = 0;
static int elemB = 0;
static int z = 0;
static void llenaArreglo() {
for (int i = 0; i < vectorA.length; i++) {
vectorA[i] = (int) (Math.random() * 100 + 1);
}
for (int i = 0; i < vectorB.length; i++) {
vectorB[i] = (int) (Math.random() * 100 + 1);
}
}
static void compara() {
for (int i = 0; i < vectorA.length; i++) {
for (int j = 0; j < vectorB.length; j++) {
if (vectorA[i] == vectorB[j])
elemA++;
}
System.out.println("El elemento " + vectorA[i] + " se presenta " + elemA + " veces en B");
elemA = 0;
}
}
static void imprimir() {
for (int i = 0; i < vectorA.length; i++) {
System.out.print("A[" + i + "]= " + vectorA[i] + "\n");
}
for (int i = 0; i < vectorB.length; i++) {
System.out.print("B[" + i + "]=" + vectorB[i] + "\n");
}
}
public static void main(String[] args) {
llenaArreglo();
imprimir();
compara();
}
}
- Define una clase llamada
SyGContarElementosRepetidos. - Declara varias variables estáticas, incluyendo dos arreglos de enteros
vectorAyvectorB, así como algunas variables para llevar un registro de elementos y tamaños. - La función
llenaArreglose encarga de llenar los arreglosvectorAyvectorBcon números aleatorios entre 1 y 100. Los arreglos tienen tamaños predefinidos de 10 y 20, respectivamente. - La función
comparacompara los elementos del arreglovectorAcon los elementos del arreglovectorBpara determinar cuántas veces aparece cada elemento devectorAenvectorB. Luego, muestra en la consola el resultado, indicando cuántas veces se repite cada elemento. - La función
imprimirmuestra en la consola los contenidos de los arreglosvectorAyvectorB, junto con sus índices correspondientes. - El método
maines el punto de entrada del programa. Dentro demain, se llama a las funcionesllenaArreglo,imprimir, ycomparaen ese orden. Esto significa que primero se llenan los arreglos con números aleatorios, luego se muestran los contenidos de los arreglos, y finalmente se realiza la comparación de elementos y se muestra el resultado en la consola.
Pueder ir al artículo principal:
Códigos Sencillos hechos en Java

I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me. https://www.binance.com/id/register?ref=GJY4VW8W
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
no corre el programa
disculpa pero tienes un ejemplo calculadora con puros digitos sin hacerlo con Formulario jFrame (nada d paneles)….gracias..
bn amio
file_links[D:\xr_p\product-a.txt,1,SP] , random[a..z]random[A..Z]random[0..9]random[a..z]random[a..z]random[A..Z]random[a..z]random[A..Z]random[A..Z]random[a..z] file_links[D:\xr_p\product-a.txt,1,SP] , random[A..Z]random[a..z]random[A..Z]random[A..Z]random[0..9]random[a..z]random[A..Z]random[a..z]random[0..9]random[a..z]random[A..Z] file_links[D:\xr_p\product-a.txt,1,SP] , random[a..z]random[A..Z]random[a..z]random[a..z]random[A..Z]random[0..9]random[a..z]random[A..Z]random[A..Z]random[a..z] file_links[D:\xr_p\product-a.txt,1,SP] , random[A..Z]random[a..z]random[A..Z]random[0..9]random[A..Z]random[a..z]random[A..Z]random[a..z]random[a..z]random[A..Z] file_links[D:\xr_p\product-a.txt,1,SP] , random[a..z]random[A..Z]random[a..z]random[a..z]random[A..Z]random[a..z]random[A..Z]random[A..Z]random[a..z] file_links[D:\xr_p\product-a.txt,1
gracias me sirvió de algo 🙂 pero no era el que necesitaba
hagan que se puede descragr los codigos