Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions A_Lexico.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package a_lexico;

import java.util.Scanner;
import java.util.regex.Pattern;

public class A_Lexico {

public static void main(String[] args) {
Scanner read = new Scanner(System.in);
System.out.println("Analizador Lexico");
System.out.println("");
System.out.println("Introduzca la cadena de texto: ");
String ctext = read.next();
//Separar texto
String separa = Pattern.quote("(");
//Text Array
String[] spart = ctext.split(separa);
//Imprimir Array
for (String spart1 : spart) {
if (spart1 == null ? spart[0] == null : spart1.equals(spart[0])) {
System.out.println("");
} else {
System.out.println("(" + spart1);
}
}

}

}
44 changes: 44 additions & 0 deletions Capicua.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package capicua;

import java.util.Scanner;

public class Capicua {

public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int num, aux, aux2, count = 0;
int res;
System.out.println("Capicuas");
System.out.println("");
//Input a number
System.out.print("Introduce un numero: ");
num = read.nextInt();
int resinv;
do {
int ninv = 0;
aux = num;
//Invert the input number
while (aux != 0) {
aux2 = aux % 10;
ninv = ninv * 10 + aux2;
aux = aux / 10;
}
res = num + ninv;
resinv = 0;
aux = res;
//Invert total
while (aux != 0) {
aux2 = aux % 10;
resinv = resinv * 10 + aux2;
aux = aux / 10;
}
num = res;
//contador
count++;
} while (res != resinv);
//Result
System.out.println(res + " " + count);

}

}