//第一个只出现一次的字符
char FirstNotRepeatingChar(char *pString)
{
if (pString == NULL)
return '\0';
const int tableSize = 256;
unsigned int hasTable[tableSize];
for (unsigned int i = 0; i < tableSize; i++)
hasTable[i] = 0;
char *pHashKey = pString;
while (*pHashKey != '\0')
hasTable[*(pHashKey++)]++;
pHashKey = pString;
while (pHashKey != '\0')
{
if (hasTable[*pHashKey] == 1)
return *pHashKey;
pHashKey++;
}
return '\0';
}
求出一个字符串中出现一次的字符
最新推荐文章于 2023-01-10 23:12:36 发布