Advertisement
Guest User

Untitled

a guest
May 27th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. const int XL = 50;
  5. int main()
  6. {
  7. int n;
  8.  
  9. char a [XL];
  10. char b [XL];
  11. char c [XL];
  12. char d [XL];
  13. char e [XL];
  14. cin >> a;
  15.  
  16. n = strlen(a);
  17.  
  18. if (n<=3)
  19. {
  20. cout << n;
  21. return 0;
  22. }
  23.  
  24.  
  25. if (n%2 == 0)
  26. {
  27.  
  28. for(int j = 0; j < n-1; j++)
  29. {
  30.  
  31. if (a[j+1] != a[n-1-j] )
  32. {
  33. cout << n-1-j;
  34. return 0;
  35. }
  36.  
  37. }
  38.  
  39.  
  40.  
  41.  
  42. }
  43.  
  44. if (n%2 != 0)
  45. {
  46. for(int j = 0; j < n-1; j++)
  47. {
  48.  
  49. if (a[j+1] != a[n-1-j] )
  50. {
  51. cout << n-1-j;
  52. return 0;
  53. }
  54.  
  55. }
  56.  
  57. }
  58.  
  59. cout << 0;
  60.  
  61.  
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement