查找关键字

#include <iostream>
using namespace std;
int main(){
    string s="qwerc++iopc++qwertyuiop",str="";
    string g;cin>>g;
    int b=0,k=0;
    while((b=s.find(g, k)) != -1){
        str+=s.substr(k,b-k);
        str+='['+g+']';
        k=b+g.size();
    }
    str+=s.substr(k); 
    cout<<str;
    return 0;
}

 

posted @ 2025-06-08 09:37  昵称就是最好的昵称  阅读(5)  评论(0)    收藏  举报