Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Created March 28, 2018 21:39
Show Gist options
  • Save pr00thmatic/4ae47eb7b4a37afa8e53ebc4c179a8b9 to your computer and use it in GitHub Desktop.
Save pr00thmatic/4ae47eb7b4a37afa8e53ebc4c179a8b9 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.Scanner;
public class Capicua {
public static void main(String[] args) {
Scanner in = new Scanner();
int n = in.nextInt();
String str = n + "";
String capi = str.substring(0, Math.floor(str.length/2));
string cua = str.substring(Math.ceil(str.length/2));
cua = new StringBuilder(cua).reverse().toString();
if (cua != capi) {
System.out.println("el número es capicúa");
} else {
System.out.println("el número no es capicúa");
}
}
}
import java.util.*;
import java.Scanner;
public class Test {
public static void main(String[] args) {
Scanner in = new Scanner();
float a, b, c;
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
try {
float x1 = (-2 * c) / (b + Math.sqrt(b*b - 4*a*c)),
x2 = (-2 * c) / (b - Math.sqrt(b*b - 4*a*c));
System.out.println(x1 + " " + x2);
} catch (Exception e) {
System.out.println("No tiene soluciones reales");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment