Advertisement
roronoa

num tel en morse

Jul 15th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.*;
  2. class Solution {
  3.  
  4.     public static void main(String args[]) {
  5.         Scanner in = new Scanner(System.in);
  6.         String mn = in.nextLine();
  7.         String[] tab = {"-----", ".----", "..---", "...--","....-", ".....", "-....", "--...","---..", "----."};
  8.         String rep = "";
  9.         if(mn.replaceAll("[^0-9]","").length() == 10 && mn.replaceAll("[0-9]","").length() == 0)
  10.             for(char c : mn.toCharArray())
  11.                 rep += tab[c-'0'] + " ";
  12.         else
  13.             rep += "Untransformable";      
  14.         System.out.print(rep.trim());  
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement