标签:substr int while end sub main 不重复 its 字符
求最小不重复匹配次数
改最后一个字符最划算
我当时怎么就没看出来..
#include<bits/stdc++.h>
using namespace std;
string S,T;
int main(){
while(cin>>S>>T){
int ans=0;
for(int i = 0; i < S.length();){
if(T==S.substr(i,T.length())){
ans++;
S[i+T.length()-1]=‘#‘;
i=i+T.length();
}
else i++;
// cout<<S<<endl;
}
cout<<ans<<endl;
}
}
标签:substr int while end sub main 不重复 its 字符
原文地址:http://www.cnblogs.com/caturra/p/8011551.html