字符串查找--B中是否有元素不在A中

时间:2020-12-09 12:54:18


#include <stdio.h>
int main(int argc, char const *argv[])
{
char str[26]="AFDKJASD";
char str2[26]="AAAAZ";
find_not_include_string(str,str2);
return 0;
} void find_not_include_string(char *str,char *sub_str)
{ int father_str[26]={0};
int sub_str[26]={0}; if (*str==NULL||*sub_str==NULL)
{
return;
} for (int i = 0; i < strlen(str); ++i)
{
father_str[str[i]-'A']++;
}
for (int i = 0; i < strlen(sub_str); ++i)
{
sub_str[sub_str[i]-'A']++;
}
for (int i = 0; i < 26; ++i)
{
if(father_str[i]==0&&sub_str[i] != 0)
{ printf("%c is not in str!\n", i+'A');
break;
}
} printf("%s\n","str2 is include by str!" );
}