#include <iostream>
#include <string>
using namespace std;
// Functie pentru a transforma un caracter in numarul corespunzator
int transformaInNumar(char c) {
if (isalpha(c)) { // Verificam daca este litera
if (isupper(c)) {
return c - 'A' + 1; // Litere mari (A = 1, B = 2, ..., Z = 26)
} else {
return c - 'a' + 1; // Litere mici (a = 1, b = 2, ..., z = 26)
}
} else {
return static_cast<int>(c); // Caractere speciale (cod ASCII)
}
}
// Functie pentru a transforma un sir de caractere
void transformaTextul(const string& text) {
for (char c : text) {
int numar = transformaInNumar(c);
cout << numar << " ";
}
cout << endl;
}
int main() {
string text;
cout << "Introduceti un text: ";
getline(cin, text);
cout << "Transformarea textului in numere: " << endl;
transformaTextul(text);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLy8gRnVuY3RpZSBwZW50cnUgYSB0cmFuc2Zvcm1hIHVuIGNhcmFjdGVyIGluIG51bWFydWwgY29yZXNwdW56YXRvcgppbnQgdHJhbnNmb3JtYUluTnVtYXIoY2hhciBjKSB7CiAgICBpZiAoaXNhbHBoYShjKSkgeyAvLyBWZXJpZmljYW0gZGFjYSBlc3RlIGxpdGVyYQogICAgICAgIGlmIChpc3VwcGVyKGMpKSB7CiAgICAgICAgICAgIHJldHVybiBjIC0gJ0EnICsgMTsgLy8gTGl0ZXJlIG1hcmkgKEEgPSAxLCBCID0gMiwgLi4uLCBaID0gMjYpCiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuIGMgLSAnYScgKyAxOyAvLyBMaXRlcmUgbWljaSAoYSA9IDEsIGIgPSAyLCAuLi4sIHogPSAyNikKICAgICAgICB9CiAgICB9IGVsc2UgewogICAgICAgIHJldHVybiBzdGF0aWNfY2FzdDxpbnQ+KGMpOyAvLyBDYXJhY3RlcmUgc3BlY2lhbGUgKGNvZCBBU0NJSSkKICAgIH0KfQoKLy8gRnVuY3RpZSBwZW50cnUgYSB0cmF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