kookjd7759   3년 전

문제시 삭제하겠습니다. 

아무래도 40개가 넘는 모스 코드를 하나씩 타이핑하는게 공부가 될 것 같지는 않으니 .., 

ydnactnim   1년 전

Java 입니다.

HashMap<String, Character> morseCode = new HashMap<String, Character>();

morseCode.put(".-", 'A');
morseCode.put("-...", 'B');
morseCode.put("-.-.", 'C');
morseCode.put("-..", 'D');
morseCode.put(".",  'E');
morseCode.put("..-.", 'F');
morseCode.put("--.", 'G');
morseCode.put("....", 'H');
morseCode.put("..", 'I');
morseCode.put(".---", 'J');
morseCode.put("-.-", 'K');
morseCode.put(".-..", 'L');
morseCode.put("--", 'M');
morseCode.put("-.", 'N');
morseCode.put("---", 'O');
morseCode.put(".--.", 'P');
morseCode.put("--.-", 'Q');
morseCode.put(".-.", 'R');
morseCode.put("...", 'S');
morseCode.put("-", 'T');
morseCode.put("..-", 'U');
morseCode.put("...-", 'V');
morseCode.put(".--", 'W');
morseCode.put("-..-", 'X');
morseCode.put("-.--", 'Y');
morseCode.put("--..", 'Z');
morseCode.put(".----", '1');
morseCode.put("..---", '2');
morseCode.put("...--", '3');
morseCode.put("....-", '4');
morseCode.put(".....", '5');
morseCode.put("-....", '6');
morseCode.put("--...", '7');
morseCode.put("---..", '8');
morseCode.put("----.", '9');
morseCode.put("-----", '0');
morseCode.put("--..--" , ',');
morseCode.put(".-.-.-" , '.');
morseCode.put("..--.." , '?');
morseCode.put("---..." , ':');
morseCode.put("-....-" , '-');
morseCode.put(".--.-." , '@');

hhj05   1년 전

Python

fill2714   11달 전

        
        if (s == ".-") cout << 'A'; else if (s == "-...") cout << 'B'; else if (s == "-.-.") cout << 'C'; else if (s == "-..") cout << 'D'; else if (s == ".") cout << 'E'; else if (s == "..-.") cout << 'F'; else if (s == "--.") cout << 'G'; else if (s == "....") cout << 'H'; else if (s == "..") cout << 'I'; else if (s == ".---") cout << 'J'; else if (s == "-.-") cout << 'K'; else if (s == ".-..") cout << 'L'; else if (s == "--") cout << 'M'; else if (s == "-.") cout << 'N'; else if (s == "---") cout << 'O'; else if (s == ".--.") cout << 'P'; else if (s == "--.-") cout << 'Q'; else if (s == ".-.") cout << 'R'; else if (s == "...") cout << 'S'; else if (s == "-") cout << 'T'; else if (s == "..-") cout << 'U'; else if (s == "...-") cout << 'V'; else if (s == ".--") cout << 'W'; else if (s == "-..-") cout << 'X'; else if (s == "-.--") cout << 'Y'; else if (s == "--..") cout << 'Z'; else if (s == ".----") cout << '1'; else if (s == "..---") cout << '2'; else if (s == "...--") cout << '3'; else if (s == "....-") cout << '4'; else if (s == ".....") cout << '5'; else if (s == "-....") cout << '6'; else if (s == "--...") cout << '7'; else if (s == "---..") cout << '8'; else if (s == "----.") cout << '9'; else if (s == "-----") cout << '0'; else if (s == "--..--") cout << ','; else if (s == ".-.-.-") cout << '.'; else if (s == "..--..") cout << '?'; else if (s == "---...") cout << ':'; else if (s == "-....-") cout << '-'; else if (s == ".--.-.") cout << '@';

댓글을 작성하려면 로그인해야 합니다.