From fdea465c58e24c7ce613ca6a5538ab8df50660af Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Tue, 31 Dec 2019 01:51:36 +0100 Subject: Resuelto 484 en java: El incidente de Dharhan. --- .../problemas/Problema484ElIncidenteDeDhahran.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 AceptaElReto/src/problemas/Problema484ElIncidenteDeDhahran.java diff --git a/AceptaElReto/src/problemas/Problema484ElIncidenteDeDhahran.java b/AceptaElReto/src/problemas/Problema484ElIncidenteDeDhahran.java new file mode 100644 index 0000000..88ba674 --- /dev/null +++ b/AceptaElReto/src/problemas/Problema484ElIncidenteDeDhahran.java @@ -0,0 +1,37 @@ +package problemas; + +public class Problema484ElIncidenteDeDhahran { + + static java.util.Scanner in; + + public static void main(String args[]) { + in = new java.util.Scanner(System.in); + String caso; + String[] partes; + String entera; + String decimal; + while (in.hasNext()) { + caso = in.nextLine(); + + partes = caso.split("\\."); + + entera = partes[0]; + entera = entera.replaceFirst("^0*", ""); + if (entera.isEmpty()) + System.out.print("0"); + else + System.out.print(entera); + + if (partes.length > 1) { + decimal = partes[1]; + decimal = decimal.replaceAll("0*$", ""); + if (decimal.isEmpty()) + System.out.println(); + else + System.out.println("." + decimal); + } + else + System.out.println(); + } + } +} \ No newline at end of file -- cgit v1.2.1