最长的对称有效密码串长度
字符串运用-密码截取
http://www.nowcoder.com/questionTerminal/12e081cd10ee4794a2bd70c7d68f5507
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ String str = sc.nextLine(); StringBuilder sb = new StringBuilder(); sb.append(str); sb.reverse(); int max = 0; for(int i = 0 ;i < str.length(); i++){ for(int j = i + 1; j < str.length(); j++){ if(str.contains(sb.substring(i,j))){ if(j - i > max){ max = j - i; } } } } System.out.println(max); } } }