【华为OJ】字符串匹配

来源:互联网 发布:淘宝卖家发顺丰多少钱 编辑:程序博客网 时间:2024/06/04 23:20

输入:短字符串  长字符串

输出:如果短字符串中的字符在长字符串中都能找到,则输出true;否则输出false。

#include <iostream>  #include <string>  using namespace std;int main(){string sho,lo;cin >> sho>>lo;int length1 = sho.size();int length2 = lo.size();int count;for (int i = 0;i < length1;i++){count = 0;for (int j = 0;j < length2;j++){if (sho[i] == lo[j])count++;}if (count == 0){cout << "false";return 0;}}if (count > 0)cout <<"true";return 0;}


0 0