#1954: I will give you the answer but one chicken cover(雞包)


1753980-3@g.puiching.edu.mo (P5A31蒲雋浠)

School : No School
ID : 2571
IP address : [192.168.120.33]
Last Login :
2025-03-20 12:13:05
b385. 摩斯電碼的秘密 | From: [192.168.120.33] | Post Date : 2025-04-15 18:43

#include <iostream>
#include <string>
#include <unordered_map>
#include <sstream>
#include <vector>

using namespace std;

int main() {
    unordered_map<string, char> morseToDigit = {
        {"-----", '0'},
        {".----", '1'},
        {"..---", '2'},
        {"...--", '3'},
        {"....-", '4'},
        {".....", '5'},
        {"-....", '6'},
        {"--...", '7'},
        {"---..", '8'},
        {"----.", '9'}
    };
    
    string input;
    getline(cin, input);
    istringstream iss(input);
    string morseCode;
    string result;
    
    while (iss >> morseCode) {
        if (morseToDigit.find(morseCode) != morseToDigit.end()) {
            result += morseToDigit[morseCode];
        }
    }
    
    cout << result << endl;
    
    return 0;
}
 
ZeroJudge Forum