题解 | #String Matching#

String Matching

https://www.nowcoder.com/practice/00438b0bc9384ceeb65613346b42e88a

#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main(){
    string S1 ;
    string S2 ;
   cin >> S1 >> S2;
    int len1 = S1.length();
    int len2 = S2.length();
    int pos =0;
    for(int i = 0 ; i < len1;++i){
        int pos2 = S1.find(S2,i);
        if(pos2 != -1){
            ++pos;
            i=pos2;
            continue;
        }
    }
    printf("%d\n",pos);
}

全部评论

相关推荐

04-17 23:48
西北大学 Java
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
04-23 10:48
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务