首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

字符串包孕

2012-09-11 
字符串包含问题描述:判断B字符串中是否有字符与与A字符串中的的字符不同如果不同的话,哪么输出false 如果

字符串包含
问题描述:判断B字符串中是否有字符与与A字符串中的的字符不同
如果不同的话,哪么输出false 如果都有 哪么输出true
例如:

ABCDEFG  ABC
输出true
ABCDEF SAD
输出false 因为S不在A中

                           #include<iostream>#include<string>#include<cstring>using namespace std;bool Compare(string str1,string str2){   int i ,j;   bool bol = false;   int str1len=str1.length();   int str2len=str2.length();   for(i=0;i<str2len;i++)   {     for(j=0;j<str1len;j++)     {       if(str1[j]==str2[i])       {         bol = true;         break;       }       else       {        bol = false;        continue;       }     }     if(bol==true)     {       continue;     }     else     {       break;     }   }   if(bol)   return true;   else   return false;}int main(){ string str1,str2; while(cin>>str1>>str2) {  if(Compare(str1,str2))  cout<<"true"<<endl;  else  cout<<"false"<<endl; } return 0 ;}

热点排行