avatar
Untitled

Guest 41 6th Dec, 2022 Unlisted

CPP 0.71 KB
                                           
                         #include <bits/stdc++.h>
using namespace std;
  
// Function to traverse the string and
// print the characters of the string
void TraverseString(string &str, int N)
{ 
    // Traverse the string
    for (int i = 0; i < N; i++) 
    {
  
        // Print current character
        if(str[i]%2==0)
        {
        cout<< char(str[i]-1)<< " ";
        }
        else
        {
        cout<< char(str[i]+1)<< " ";
        }
    }
      
}
  
// Driver Code
int main()
{
    string str = "abcdefghijklmoprstquwyxz";
      
    // Stores length of the string
    int N = str.length();

    TraverseString(str, N);
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
Ta strona używa plików cookie w celu usprawnienia i ułatwienia dostępu do serwisu oraz prowadzenia danych statystycznych. Dalsze korzystanie z tej witryny oznacza akceptację tego stanu rzeczy.
Wykorzystywanie plików Cookie
Jak wyłączyć cookies?
ROZUMIEM