morse completed
This commit is contained in:
		
							parent
							
								
									deebdedc1b
								
							
						
					
					
						commit
						04f920ac2d
					
				
					 2 changed files with 4 additions and 4 deletions
				
			
		|  | @ -5,8 +5,8 @@ int main() { | ||||||
|     Morse_code mc{"morse.def"}; |     Morse_code mc{"morse.def"}; | ||||||
|     std::cout << mc.encode("Hello Morse") << "\n"; // .... . .-.. .-.. --- -- --- .-. ... .
 |     std::cout << mc.encode("Hello Morse") << "\n"; // .... . .-.. .-.. --- -- --- .-. ... .
 | ||||||
|      |      | ||||||
| //     std::cout << mc.decode("... --- ...") << "\n";
 |     std::cout << mc.decode("... --- ...") << "\n"; | ||||||
| //     std::cout << mc.decode(".... ----") << "\n"; // ---- is not a valid code
 |     std::cout << mc.decode(".... ----") << "\n"; // ---- is not a valid code
 | ||||||
| //     std::cout << mc.decode(mc.encode("loopback test")) << "\n";
 |     std::cout << mc.decode(mc.encode("loopback test")) << "\n"; | ||||||
| // 
 | // 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ std::string Morse_code::decode(std::string str) { | ||||||
|     std::string s; |     std::string s; | ||||||
|     while(in >> s) { |     while(in >> s) { | ||||||
|          |          | ||||||
|         auto it = std::find_if(morse_map.begin(), morse_map.end(), [&](std::pair<char, std::string> &p) { |         auto it = std::find_if(morse_map.begin(), morse_map.end(), [&](std::pair<const char, std::string> &p) { | ||||||
|             return p.second == s; |             return p.second == s; | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Borean
						Borean