文章

166

粉丝

68

获赞

855

访问

61.6k

头像
字符串 题解:find函数帮大忙
P1195 华南师范大学机试
发布于2025年3月2日 13:19
阅读数 289

#include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    while(cin>>n){
        vector<string>a(n);
        for(int i=0;i<n;i++)cin>>a[i];
        int q;cin>>q;
        while(q--){
            string b;cin>>b;
            int ans=0;
            for(auto x:a){
                if(x.find(b)==0)ans++;
            }
            cout<<ans<<endl;
        }
    }
}

你不需要写匹配函数,或者写前缀匹配函数,cpp为你准备好了最好用的自带的kmp算法

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发