Promi_38

cf 981A

Dec 24th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int isPalin (char str[], int len)
  5. {
  6.     int i, h = len / 2;
  7.     for (i = 0; i < h; i++) if (str[i] != str[len - i - 1]) return 0;
  8.     return 1;
  9. }
  10.  
  11. int retLen (char str[], int len)
  12. {
  13.     if (len == 0) return 0;
  14.     if (isPalin(str,len)) retLen(str, --len);
  15.     else return len;
  16. }
  17.  
  18. int main ()
  19. {
  20.     char str[50];
  21.     int len,i;
  22.  
  23.     scanf("%s", str);
  24.     len = strlen(str);
  25.  
  26.     printf("%d\n",retLen(str,len));
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment