From 04f920ac2d3bd069cc4e30d80eef457ba17ee3b2 Mon Sep 17 00:00:00 2001 From: Borean <> Date: Sun, 12 Jan 2025 16:03:36 +0100 Subject: [PATCH] morse completed --- morse/main.cc | 6 +++--- morse/morse_code.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/morse/main.cc b/morse/main.cc index db97661..e2a7610 100644 --- a/morse/main.cc +++ b/morse/main.cc @@ -5,8 +5,8 @@ int main() { Morse_code mc{"morse.def"}; std::cout << mc.encode("Hello Morse") << "\n"; // .... . .-.. .-.. --- -- --- .-. ... . -// std::cout << mc.decode("... --- ...") << "\n"; -// std::cout << mc.decode(".... ----") << "\n"; // ---- is not a valid code -// std::cout << mc.decode(mc.encode("loopback test")) << "\n"; + std::cout << mc.decode("... --- ...") << "\n"; + std::cout << mc.decode(".... ----") << "\n"; // ---- is not a valid code + std::cout << mc.decode(mc.encode("loopback test")) << "\n"; // } diff --git a/morse/morse_code.cc b/morse/morse_code.cc index 36ec13a..4950f83 100644 --- a/morse/morse_code.cc +++ b/morse/morse_code.cc @@ -31,7 +31,7 @@ std::string Morse_code::decode(std::string str) { std::string s; while(in >> s) { - auto it = std::find_if(morse_map.begin(), morse_map.end(), [&](std::pair &p) { + auto it = std::find_if(morse_map.begin(), morse_map.end(), [&](std::pair &p) { return p.second == s; });