首页 > 代码库 > Mr. Kitayuta's Gift

Mr. Kitayuta's Gift

技术分享
 1 //回文判断 Codeforces Round #286 (Div. 2)
 2 #include<iostream>
 3 #include<cstdio> 
 4 int main()
 5 {
 6     string f,temp; cin>>f;
 7     int len(f.size());
 8     for(char c =a;c<=z;c++)
 9     {
10         temp.clear();
11         temp.push_back(c);
12         for(int i=0;i<=len;i++)
13         {
14             string spre = f.substr(0,i);
15             string stail = f.substr(i,len-i);
16             string s1 = spre + temp + stail;
17             string s2 = s1;
18             reverse(s2.begin(),s2.end());   //翻转字符串
19             if(s1 == s2) {cout<<s1<<endl;return 0;}
20         }
21     }
22     printf("NA\n");
23     return 0;
24 }
View Code

 

Mr. Kitayuta's Gift