#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char a[100];
char b[100];
int c[10],temp1=0,temp2=0,i=0,j=0,count=0;//temp1 temp2为字符串a,b的指针
printf("请输入字符串:\n");
gets(a);
b[0] = a[0];
b[1] = '\0';
while(1)//将a中不同的字符提取到b中
{
if(a[temp1] == '\0')
break;
for(temp2=0;;temp2++)
{
if(b[temp2] == '\0')
break;
if(a[temp1] == b[temp2])
break;
}
if(b[temp2] == '\0')//扫描结束后在b中没有发现相同字符
{
b[temp2] = a[temp1];
b[temp2+1] = '\0';
}
temp1++;
}
temp1 = 0;
temp2 = 0;
while(b[temp2]!='\0')
{
while(a[temp1]!='\0')
{
if(a[temp1] == b[temp2])
count++;
temp1++;
}
c[j++] = count;
count=0;temp1 = 0;//将数据复位
temp2++;
}
while(b[i]!='\0')
{
printf("%c ",b[i]);
i++;
}
//printf("大小%d",strlen(b));
printf("\n");
for(i=0;i<j;i++)
printf("%d ",c[i]);
return 0;
}