diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2019-12-31 01:51:36 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2019-12-31 01:51:36 +0100 |
commit | fdea465c58e24c7ce613ca6a5538ab8df50660af (patch) | |
tree | 5f15f7cbc3e2f20dbba4d448dd4a0aaa116ebc41 | |
parent | a107d3a0a452da563acfe1fac1a5463ecf95a951 (diff) | |
download | AceptaElReto-fdea465c58e24c7ce613ca6a5538ab8df50660af.tar.gz AceptaElReto-fdea465c58e24c7ce613ca6a5538ab8df50660af.zip |
Resuelto 484 en java: El incidente de Dharhan.
-rw-r--r-- | AceptaElReto/src/problemas/Problema484ElIncidenteDeDhahran.java | 37 |
1 files changed, 37 insertions, 0 deletions
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 |