Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include static const char symbol[] = "abcdefghijklmnopqrstuvwxyz"; char convert(char c, int shift) { if (c < 'a' || c > 'z') return c; return symbol[(c - 'a' + shift) % (sizeof (symbol) - 1)]; } std::string convert(const std::string& s, int shift) { std::string res; res.resize(s.size()); for (unsigned int i = 0; i < s.size(); ++i) res[i] = convert(s[i], shift); return res; } int main() { std::string txt; const int shift = 3; // choix de la valeur de décalage std::cout << "Saisir texte "; std::cin >> txt; std::cout << "Texte: "<< txt << std::endl << "Texte chiffré: " << convert(txt, shift) << std::endl; return 0; }