字符串统计满2的进行拼接
package Campus; import java.util.Scanner; public class Test_T1 { public static void main(String[] args) { StringBuffer s=joint(); System.out.println(s); } public static StringBuffer joint(){ Scanner cin = new Scanner(System.in); String str = cin.next(); char[] a = str.toCharArray(); int count, len = a.length; for(int i = 0; i < len - 1; i++){ count = 0; for(int j = i+1; j < len; j++){ if (a[j] != 0 && a[j] == a[i]){ count = count + 1; a[j] = 0; } } if (count == 0 || count > 1) a[i] = 0; } StringBuffer str1 = new StringBuffer(); for(int i = 0; i < len; i++){ if (a[i] != 0) str1.append(a[i]); } return str1; } }