把一种字符串替换成另一种,STL类型的题

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     string S,T,P;
 6     cin>>S>>T>>P;
 7     int len=T.size();
 8     while(1){
 9         int pos=S.find(T);
10         if(pos==-1) break;
11         S.replace(pos,len,P);
12     }
13     cout<<S<<endl;
14     return 0;
15 }