代码如下:
public static void main(String[] args) {
Scanner n =new Scanner(System.in);
String n1 = n.nextLine();
char[]x1 = n1.toCharArray();
int count = 0;
int b = 0;
char c = x1[b];
while (b <= x1.length)
{
if (c == x1[b])
{
count++;
b++;
}
else
{
System.out.print((char) c+""+count);
count = 0;
b++;
c = x1[b];
}
}
}