text: Program to find the Encrypted word | C ++ program to implement the above approach ; Function to find the encrypted string ; to store the encrypted string ; after ' z ' , it should go to a . ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; void findWord ( string c , int n ) { int co = 0 , i ; string s ( n , ' ▁ ' ) ; for ( i = 0 ; i < n ; i ++ ) { if ( i < n / 2 ) co ++ ; else co = n - i ; if ( c [ i ] + co <= 122 ) s [ i ] = ( char ) ( ( int ) c [ i ] + co ) ; else s [ i ] = ( char ) ( ( int ) c [ i ] + co - 26 ) ; } cout << s ; } int main ( ) { string s = " abcd " ; findWord ( s , s . length ( ) ) ; return 0 ; }