|  | 
|  | 
| вернуться в форум | SEE THIS SOLUTON! I LIKE IT! #include "iostream"#include "string"
 #include "vector"
 using namespace std;
 bool is_palindrom (string s,int nach,int krai) {
 for (int i=nach,j=krai;i<=j;i++,j--) if (s[i]!=s[j]) return false;
 return true;
 }
 int main () {
 char ch;
 string s,s1,spal;
 int j=-1,mx=-1;
 while (cin>>ch) {
 s+=ch;
 j++;
 int i=-1;
 string s1=s;
 vector<int>a;
 do {
 i++;
 if (s1[i]==ch) a.push_back(i);
 }
 while (i<=s1.length());
 for (int i=0;i<a.size();i++)
 if (is_palindrom(s1,a[i],j)) {
 string s2=s1.substr(a[i],j-a[i]+1);
 int l=s2.length();
 if (l>mx) {mx=l;spal=s2;break;}
 }
 }
 cout<<spal<<endl;
 system ("pause");
 return 0;
 }
Re: SEE THIS SOLUTON! I LIKE IT! Послано AlMag  9 авг 2008 20:09Why're u doing this?For Author! Stop posting your own solutions! Admins will add you to ban list (see rules of behavior for this web-site)... And try to solve something interesting and really hard...
 Edited by author 10.08.2008 00:26
 | 
 | 
|