- #include<iostream>
- #include<cstdlib>
- #include<string>
- #include<algorithm>
- using namespace std;
- int main()
- {
- string a1="bengchiling";
- cout<<a1<<endl;
- cout<<a1.replace(4,1,"Z")<<endl;
- string a2="bengchiling";
- cout<<a2.replace(a2.find("g"),1,"QQ")<<endl;
- cout<<a2.replace(a2.find("g"),1,"QQ")<<endl;
- string a3="bengchiling";
- replace(a3.begin(),a3.end(),'n','o');
- cout<<a3<<endl;
- }
複製代碼 |