当前位置:编程学习 > C/C++ >>

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

 
<PRE class=cpp name="code" sizcache="1" sizset="4"><PRE class=cpp name="code">#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!" );  
}</PRE>  
<PRE></PRE>  
<PRE></PRE>  
<PRE></PRE>  
  
</PRE>  

 

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,