mardi 22 septembre 2020

How can I replace every alphabetical lower case letter in a string with its opposite alphabetical lower case letter in C++? [closed]

I would like to find the opposite letter using for loop. Also, I would like to note that I am trying to find the opposite letter. For example, replacing "a" with "z", "b" with "y"...

For example, the user inputs this: "3 feg", and the output from this program will be: "uvt". Also, my constraint is 1<=n<=100. The input format is "n input_string_of_length_n", and the output format is "encrypted_string_of_length_n". As a new beginner to programming, I am lost and I do not know how to solve this. Any help will be very much appreciated.

This is my code:


    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
        `int` user_input_number;
        string user_input_text;
    
        cout << "Type: ";
        cin >> user_input_number;
    
        cout << "Type: ";
        cin >> user_input_text;
    
        for(char i = 'a'; i <= 'z'; i++)
        {
         cout <<  << endl;
        }
        return 0;
    }
    
    
      

Aucun commentaire:

Enregistrer un commentaire