#include <stdio.h>
#include <string.h>
int main()
{
int times,num[385],k,i,len,j;
int n;
char c[100][10000],copy[27];
puts("Please Input N :");
scanf("%d",&n);
puts("Well,input the strings:");
for(times=0;times<n;times++)
{
scanf("%s",c[times]);
}
/*
for(times=0;times<n;times++)
{
len=strlen(c[times]);
for(i=0,j=1;i<len-1;i++)
//i+1的话就不能用i < len了
{
copy[0]=c[times][0];
if(copy[j-1]!=c[times][i+1])
//这个语句只是可以区分相邻的元素,要是出现ABA这种情况呢?
{
copy[j]=c[times][i+1];
j++;
}
}
*/
for(times = 0; times < n; times++)
{
len = strlen(c[times]);
j = 0;
copy[0] = c[times][0];
for(i = 0; i < len - 1; i++)
{
for(k = 0; k <= j && copy[k] != c[times][i+1]; k++);
if(k > j)
{
copy[++j] = c[times][i+1];
}
}
for(i=0;i<=j;i++)
{
num[i]=0;
for(k=0;k<len;k++)
{
if(copy[i]==c[times][k])
num[i]++;
}
}
for(i=0;i<=j;i++)
printf("%d%c",num[i],copy[i]);
printf("\n");
}
}