功能: 判断短字符串中的所有字符是否在长字符串中全部出现
#include <stdlib.h>
#include <string.h>
/*
输入:char * pShortString :短字符串
char * pLongString :长字符串
输出:无
返回:TRUE - 表示短字符串中所有字符均在长字符串中出现
FALSE - 表示短字符串中有字符在长字符串中没有出现
*/
bool IsAllCharExist(char * pShortString, char * pLongString)
{
/*在这里实现功能*/
if ((NULL == pShortString) || (NULL == pLongString))
{
return false;
}
if (("" == pShortString) || ("" == pLongString))
{
return false;
}
char *pShortTmp = NULL;
char *pLongTmp = NULL;
int aHashTb[256] = { 0 };
memset(aHashTb, 0, sizeof(aHashTb));
for (pLongTmp = pLongString; *pLongTmp; pLongTmp++)
{
aHashTb[*pLongTmp] = 1;
}
for (pShortTmp = pShortString; *pShortTmp; pShortTmp++)
{
if (0 == aHashTb[*pShortTmp])
{
return false;
}
}
return true;
}