//we are students --- aeiou === w r stdnts
char* DeleteTwoInOne(char first[],char second[])
{
if (first == NULL || second == NULL)
return NULL;
int i;
const int TableSize = 256;
unsigned int hashTable[TableSize];
for (i = 0; i < TableSize; i++)
{
hashTable[i] = 0;
}
char *secondkey = second;
while (*(secondkey) != '\0')
{
hashTable[*(secondkey++)]++;
}
char *firstkey = first;
char *result,*temp;
result = firstkey;
while (*firstkey)
{
if (hashTable[*firstkey] == 1)
{
temp = firstkey;
while (*temp)
{
*(temp) = *(temp + 1);
temp++;
}
}
firstkey++;
}
return result;
}两个字符串A,B,在A中删除B的元素
最新推荐文章于 2021-11-09 10:41:56 发布
本文介绍了一种从一个字符串中移除另一个字符串中所有字符各一次的算法实现。通过使用哈希表记录第二个字符串中每个字符出现的情况,然后遍历第一个字符串并删除其中与哈希表记录匹配的字符。
1817

被折叠的 条评论
为什么被折叠?



