使用为位图法,查找字符串中第一个不重复的字符,使用位图法,该字符是数组的index,而出现的次数则是数值
char find_first_single_char(const char *str)
{
int tmp[256]={0};
char *s= (char *)str;
while(*s!='\0')
{
tmp[*s]++;
s++;
}
s=(char*)str;
while(*s!='\0')
{
if(tmp[*s]==1)
{
return *s;
}
s++;
}
return '\0';
}