金海佳学C++primer9.45/9.46
string加前缀和后缀
Practice 9.45
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iterator>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <sstream>
using namespace std;string add_pre_post(string s, string pre, string post) {s.insert(0, pre);s.append(post);return s;
}int main() {string s, pre, post;cin >> s >> pre >> post;cout << "s: " << s << endl;cout << "pre: " << pre << endl;cout << "post: " << post << endl;cout << add_pre_post(s, pre, post) << endl;return 0;
}
Output
Practice
s: Haijia
pre: Ms.
post: Jin
Ms.HaijiaJin
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iterator>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <sstream>
using namespace std;string add_pre_post_2(string s, string pre, string post) {s.insert(0, pre);s.insert((int)s.length(), post);return s;
}int main() {string s, pre, post;cin >> s >> pre >> post;cout << "s: " << s << endl;cout << "pre: " << pre << endl;cout << "post: " << post << endl;cout << add_pre_post_2(s, pre, post) << endl;return 0;
}
Output
s: Haijia
pre: Ms.
post: Jin
Ms.HaijiaJin
刚才矫情了。
金海佳学C++primer9.45/9.46相关推荐
- 金海佳学C++primer 练习9.15/9.16
判断两个vector是否相等 Practice9.15 #include <iostream> #include <string> #include <vector> ...
- 金海佳学C++primer 练习9.47
用find_first_of筛分字符串 Practice 9.47 #include <iostream> #include <queue> #include <stri ...
- 金海佳学C++primer 练习9.44
string中替换oldVal->newVal(using replace) Practice 9.44 #include <iostream> #include <queue ...
- 金海佳学C++primer 练习9.43
string中替换oldVal->newVal Practice 9.43 #include <iostream> #include <queue> #include & ...
- 金海佳学C++primer 练习9.31
forward_list复制奇数删除偶数 Practice9.31 #include <iostream> #include <queue> #include <stri ...
- 金海佳学C++primer 练习9.41
vector(char)初始化 string Practice 9.41 #include <iostream> #include <queue> #include <s ...
- 金海佳学C++primer 练习9.27
查找并删除forward_list中的奇数元素 Practice 9.27 #include <iostream> #include <string> #include < ...
- 金海佳学C++primer 练习9.28
forward_list中查找str1并将str2插到后面 Practice 9.28 #include <iostream> #include <string> #inclu ...
- 金海佳学C++primer 练习9.20
将list中的元素按奇偶分到两个deque中 Practice 9.20 #include <iostream> #include <string> #include < ...
最新文章
- 复习计算机网络基础 day8--传输层
- 杭电2682--Tree(Prim)
- bootstrap布局两列或者多列表单
- 如何实现轮播图的内容的多少随div的大小动态变化_小程序学习日志8:swiper滑动轮播组件(轮播图)(上)...
- Git 原理详解及实用指南
- 佳肴_纪中1420_dfs
- (6)tcp-socket
- IDEA自定义快捷键
- 广义表的存储结构算法c语言,广义表(一)
- HDU 2176:取(m堆)石子游戏(Nim博弈)
- 全面|机房精密空调设计,看完你就明白了
- Shell判断字符串是否为空
- 基于SRP创建自定义渲染管线
- PKI体系与CA证书
- 档案管理系统,项目总结
- 凑微分公式_不定积分的计算凑微分法.ppt
- matlab char 转asc码,科学网—C语言与MATLAB对二进制文件与ASCII文件转换 - 张凌的博文...
- Word文档进入只读模式
- ubuntu 安装 hustoj
- web前端-仿优车诚品首页二级分类菜单
热门文章
- linux通过无线网卡上网,在Kubuntu Linux下轻松使用无线上网卡
- 软件工程课程学习小组项目——网上书店
- 中职计算机英语教师教学总结,中职教师工作总结
- log4j2 pattern详解
- 恶意代码分析之简单键盘记录器
- HDFS健康检查 hdfs fsck
- python修改pdf文件名称_使用Python重命名pdf文件目录几乎可以工作
- python获取当前时间的函数_Python日期与时间
- 计算机专业英语完形填空,英语专业四级完形填空练习附答案
- python翻页爬豆瓣影评_Python超级简单的爬虫案例--爬豆瓣影评为例