// @author @TungWah @Yue Wang// @date 4 Oct, 2014. Oct, 2015.//// Exercise 9.45:// Write a funtion that takes a string representing a name and two other// strings representing a prefix, such as "Mr." or "Ms." and a suffix,// such as "Jr." or "III". Using iterators and the insert and append functions,// generate and return a new string with the suffix and prefix added to the// given name.//#include <iostream>#include <string>using std::string;using std::cin;using std::cout;using std::endl;// Exercise 9.45auto add_pre_and_suffix(string name, string const& pre, string const& su){name.insert(name.begin(), pre.cbegin(), pre.cend());return name.append(su);}int main(){string name("Wang");cout << add_pre_and_suffix(name, "Mr.", ", Jr.") << endl;return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。