#include <iostream>
#include <string>
using namespace std;
int main( ) {
string texto = "" ;
while ( true ) {
int num;
cout << "Digite o numero binario de 8 dígitos (dígite 0 para parar): " ;
cin >> num;
cout << endl;
if ( num == 0 ) {
break ;
}
int dec = 0 , d = 1 ;
do {
dec + = num % 10 * d;
d * = 2 ;
num / = 10 ;
} while ( num ! = 0 ) ;
if ( ! ( ( dec >= 65 && dec <= 90 ) || ( dec >= 97 && dec <= 122 ) ) ) {
cout << "Valor digitado está fora da faixa permitida" << endl;
continue ;
}
texto + = "ABCDEFGHIJKLMNOPQRSTUVXYZ" [ ( dec & ~32 ) - 65 ] ;
}
cout << texto;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglzdHJpbmcgdGV4dG8gPSAiIjsKCXdoaWxlICh0cnVlKSB7CgkgICAgaW50IG51bTsKCSAgICBjb3V0IDw8ICJEaWdpdGUgbyBudW1lcm8gYmluYXJpbyBkZSA4IGTDrWdpdG9zIChkw61naXRlIDAgcGFyYSBwYXJhcik6ICI7CgkgICAgY2luID4+IG51bTsKCSAgICBjb3V0IDw8IGVuZGw7CgkgICAgaWYgKG51bSA9PSAwKSB7CgkgICAgCWJyZWFrOwoJICAgIH0KCSAgICBpbnQgZGVjID0gMCwgZCA9IDE7CgkgICAgZG8gewoJCSAgICBkZWMgKz0gbnVtICUgMTAgKiBkOwoJCSAgICBkICo9IDI7CgkJICAgIG51bSAvPSAxMDsKCSAgICB9IHdoaWxlIChudW0gIT0gMCk7CgkgICAgaWYgKCEoKGRlYyA+PSA2NSAmJiBkZWMgPD0gOTApIHx8IChkZWMgPj0gOTcgJiYgZGVjIDw9IDEyMikpKSB7CiAgIAkJICAgIGNvdXQgPDwgIlZhbG9yIGRpZ2l0YWRvIGVzdMOhIGZvcmEgZGEgZmFpeGEgcGVybWl0aWRhIiA8PCBlbmRsOwogICAgICAgICAgICBjb250aW51ZTsgCgkgICAgfQoJICAgIHRleHRvICs9ICJBQkNERUZHSElKS0xNTk9QUVJTVFVWWFlaIlsoZGVjICYgIH4zMikgLSA2NV07Cgl9CiAgICBjb3V0IDw8IHRleHRvOwogICAgcmV0dXJuIDA7Cn0=