#include <string>
#include <cctype>
#include <iostream>
#include <unordered_map>
std:: unordered_map < char , std:: string > substitute_for =
{
{ 'A' , "100 0001" } , { 'B' , "100 0010" } , { 'C' , "100 0011" } , { 'D' , "100 0100" } ,
{ 'E' , "100 0101" } , { 'F' , "100 0110" } , { 'G' , "100 0111" } , { 'H' , "100 1000" } ,
{ 'I' , "100 1001" } , { 'J' , "100 1010" } , { 'K' , "100 1011" } , { 'L' , "100 1100" } ,
{ 'M' , "100 1101" } , { 'N' , "100 1110" } , { 'O' , "100 1111" } , { 'P' , "101 0000" } ,
{ 'Q' , "101 0001" } , { 'R' , "101 0010" } , { 'S' , "101 0011" } , { 'T' , "101 0100" } ,
{ 'U' , "101 0101" } , { 'V' , "101 0110" } , { 'W' , "101 0111" } , { 'X' , "101 1000" } ,
{ 'Y' , "101 1001" } , { 'Z' , "101 1010" }
} ;
std:: string convert( const std:: string & text)
{
std:: string result;
for ( auto ch : text)
{
if ( std:: isalpha ( ch) ) result + = substitute_for[ std:: toupper ( ch) ] ;
else result + = ch;
}
return result;
}
int main( )
{
std:: string text;
std:: cout << "Enter statement you would like to convert to binary:\n > " ;
std:: getline ( std:: cin , text) ;
std:: cout << convert( text) << '\n ' ;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dW5vcmRlcmVkX21hcD4KCnN0ZDo6dW5vcmRlcmVkX21hcDxjaGFyLCBzdGQ6OnN0cmluZz4gc3Vic3RpdHV0ZV9mb3IgPQp7CiAgICB7ICdBJywgIjEwMCAwMDAxIiB9LCB7ICdCJywgIjEwMCAwMDEwIiB9LCB7ICdDJywgIjEwMCAwMDExIiB9LCB7ICdEJywgIjEwMCAwMTAwIiB9LAogICAgeyAnRScsICIxMDAgMDEwMSIgfSwgeyAnRicsICIxMDAgMDExMCIgfSwgeyAnRycsICIxMDAgMDExMSIgfSwgeyAnSCcsICIxMDAgMTAwMCIg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