-
Title Description:
-
Enter a string that prints the maximum length of the symmetric substring in the string.
For example, the input string "Google", because the longest symmetric substring in the string is "goog", so output 4.
-
Input:
-
There are multiple sets of data, one string for each group of data, and no longer than 100.
-
Output:
-
The maximum length of the output palindrome substring.
-
Sample input:
-
Google
-
-
Sample output:
-
4
1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <algorithm>5#include <iostream>6#include <cmath>7 Chartemp[102];8 intcnt[102];9 Ten intFINDHJ (intNintLen) { One inti = n1, j = n+1; A intAns =1; - while(I >=0&& J <Len) { - if(Temp[i]! =Temp[j]) { the returnans; - } -i--; -J + +; +Ans = ans +2; - } + returnans; A } at - intFindho (intNintLen) { - if(n +1> len-1) { - return 1; - } - if(Temp[n]! = temp[n+1]) { in return 1; - } to inti = n1, j = n+2; + intAns =2; - while(I >=0&& J <Len) { the if(Temp[i]! =Temp[j]) { * returnans; $ }Panax Notoginsengi--; -J + +; theAns = ans +2; + } A returnans; the } + - intMainintargcChar Const*argv[]) $ { $ while(SCANF ("%s", temp)! =EOF) { - intLen =strlen (temp); - intMax =0; the for(inti =0; i < Len; i++) { - inttemp =Findhj (i, Len);Wuyi if(Max <temp) { theMax =temp; - } Wutemp =Findho (i, Len); - if(Max <temp) { AboutMax =temp; $ } - } -printf"%d\n", max); - } A + return 0; the}
Nine degrees OJ topic 1252: palindrome string