首页 > 其他 > 详细

Mr. Kitayuta's Gift

时间:2017-04-01 16:21:16      阅读:239      评论:0      收藏:0      [点我收藏+]
技术分享
 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

原文:http://www.cnblogs.com/NWUACM/p/6656408.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!