int main()
{
string a, b;
//a = "sghrdhgukh";
cin >> a;
b.replace(b.begin(), b.end(), a.rbegin(), a.rend());
//b=a.replace(a.find("r"), 2, "g");
//b替换指定a中的指定字符(pos,len, string),pos起始位置,替换len长度个字符
//b = a.replace(a.begin(), a.begin() + 5, "p");
//b替换起始位置的n个字符,或a.end()全部字符
//string c = "world";
//b = a.replace(1, 4, c, c.find("w"), 5);
//b利用c指定长度字符替换a中指定长度的字符,(a_pos,a_len,string&c,c_pos,c_len)
//char c = 'o';
//b = a.replace(0, 6, 4, c);
//用c中的字符按规定重复次数替换a中的指定长度字符(a_pos,a_len,c_n,char&c)
//char c = 'o';
//b = a.replace(a.begin(),a.begin()+6,4, c);
cout <<b<< endl;
system("pause");
}
C++——1,字符串逆序输出(扩充repalce()函数)
最新推荐文章于 2024-07-04 00:53:48 发布