Advertisement
Saleh127

hackerearcth palindrome

Sep 29th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. string a;
  11. ll c,d,e,f=0,i,j,k,l;
  12. cin>>a;
  13.  
  14. for(i=0;i<a.size();i++)
  15. {
  16. if(a[i]==a[0])
  17. {
  18. f++;
  19. }
  20. }
  21. if(f==a.size()) cout<<0<<endl;
  22. else
  23. {
  24. string c;
  25. c=a;
  26. reverse(c.begin(),c.end());
  27. if(c==a) cout<<a.size()-1<<endl;
  28. else cout<<a.size()<<endl;
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement