知识点 | 字符串,循环,指针 |
---|---|
运行时间限制 | 10M |
内存限制 | 128 |
输入 | 输入两个字符串。第一个为短字符,第二个为长字符。 |
输出 | 返回值: true - 表示短字符串中所有字符均在长字符串中出现 false- 表示短字符串中有字符在长字符串中没有出现
|
样例输入 | bc abc |
样例输出 | true |
#include <iostream>
#include <string>using namespace std;
int main()
{
string strL,strS;//分别代表长字符串和短字符串
getline(cin,strS);//读输入行
getline(cin,strL);
int lenS=strS.size();//短字符串长度
int lenL=strL.size();//长字符串长度
int flag=0;
for(int i=0;i<lenS;i++)
{
for(int j=0;j<lenL;j++)
{
if(strS[i]==strL[j])
{
flag=1;
break;
}
}
if(0==flag)
{
cout<<"false"<<endl;
return 0;
}
flag=0;
}
cout<<"true"<<endl;
return 0;
}