fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. string pallindrom(string s){
  7. string k;
  8. string r;
  9. int i=s.size();
  10. while(i>0){
  11. for(int j=0;j<=(s.size()-i);j++){
  12. k.insert(k.end(),s.begin()+j,s.begin()+j+i);
  13. r=k;
  14. reverse(k.begin(),k.end());
  15. if(k==r)return k;
  16. k.clear();
  17. r.clear();
  18. }
  19. i--;
  20. }
  21. }
  22. int main() {
  23. // your code goes here
  24. string s="";
  25. cout<<pallindrom(s)<<endl;
  26. return 0;
  27. }
Success #stdin #stdout 0s 4344KB
stdin
Standard input is empty
stdout