Advertisement
fc-UNI_2015

p5) Mr. Kitayuta's Gift

Dec 12th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1.  
  2. #include<iostream>
  3. #include<string>
  4. #include<cstdio>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9.  
  10.     string s, aux;
  11.     cin >> s;
  12.        
  13.     for(int i = 0; i <= s.size(); i++){
  14.  
  15.         for(char c = 'a'; c <= 'z'; c++){
  16.  
  17.             aux = s.substr(0, i);
  18.             aux += c;
  19.             if(i < s.size())aux += s.substr(i);
  20.            
  21.             bool pal = true;
  22.             for(int l = 0, r = aux.size() - 1; l < r; l++, r--)if(aux[l] != aux[r])pal = false;
  23.        
  24.             if(pal){
  25.            
  26.                 cout <<aux << endl;
  27.                 return 0;
  28.             }
  29.         }
  30.        
  31.        
  32.     }
  33.     puts("NA");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement