-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanagrama.java
More file actions
25 lines (24 loc) · 746 Bytes
/
anagrama.java
File metadata and controls
25 lines (24 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class anagrama {
public static void main(String[] args) {
char[] palabra1 = {'a','m','o','r'};
char[] palabra2 = {'r','o','m','a'};
int contador = 0;
int long_palabra1 = palabra1.length;
int long_palabra2 = palabra2.length;
for(int i = 0; i < long_palabra1; i++){
for(int j = 0; j < long_palabra2; j++){
if (palabra1[i] == palabra2[j]) {
contador++;
palabra2[j] = ' ';
break;
}
}
}
if (contador == long_palabra1) {
System.out.print("son anagramas");
}
else{
System.out.print("no son anagramas");
}
}
}