```java import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); String str = scan.next(); char[] a = new char[str.length()]; int max = 0, m = 0, n = 0; int flag = 0; for (int i = 0; i < str.length(); i++) { a[i] = str.charAt(i); } for (int i = 0; i < str.length(); i++) { for (int j = i + 1; j < str.length(); j++) { if (a[j - 1] == a[j] && max != 0) { flag++; break; } if (a[j] == a[i] && j - i + 1 > max) { max = j - i + 1; m = i; n = j; break; } } } System.out.println(flag); for (int i = m; i <= n; i++) System.out.print("" + a[i]); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)