您的位置:首页 > 其它

华为oj初级 字符串匹配

2017-03-11 14:57 162 查看
描述

题目标题:

判断短字符串中的所有字符是否在长字符串中全部出现

详细描述:

接口说明

原型:

boolIsAllCharExist(char* pShortString,char* pLongString);

输入参数:

char* pShortString:短字符串

char* pLongString:长字符串

知识点 字符串,循环,指针

运行时间限制 10M

内存限制 128

输入

输入两个字符串。第一个为短字符,第二个为长字符。

输出

返回值:

true - 表示短字符串中所有字符均在长字符串中出现

false- 表示短字符串中有字符在长字符串中没有出现

样例输入 bc abc

样例输出 true

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
string s1;
string s2;
cin >> s1 >> s2;
if (s1.find_last_not_of(s2) == string::npos){
cout << "true";
}
else{
cout << "false";
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: