博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++ primer习题9.34, 9.35, 9.40
阅读量:6954 次
发布时间:2019-06-27

本文共 1213 字,大约阅读时间需要 4 分钟。

hot3.png

使用迭代器将string对象中的字符都改为大写字母

#include 
#include 
#include 
using namespace std;int main(){    string str="This is a example";    for(string::iterator iter=str.begin();iter!=str.end(); ++iter)    {        *iter=toupper(*iter);//将字符转换为对应的大写字母    }    //输出查看结果    cout<
<

使用迭代器寻找和删除string对象中所有的大写字符

#include 
#include 
#include 
using namespace std;int main(){    string str="This IS A example";    for(string::iterator iter=str.begin();iter!=str.end(); ++iter)    {        if(isupper(*iter))        {            str.erase(iter);            --iter;        }    }    //输出查看结果    cout<
<

#include 
#include 
#include 
using namespace std;int main(){    string q1("When lilacs last in the dooryard bloom'd");    string q2("The child is father of the man");    string sentence;    //将sentence赋值为"The child is "    sentence.assign(q2.begin(),q2.begin()+13);    //在sentence末尾添加"in the dooryard"    sentence.append(q1.substr(q1.find("in"), 15));    //输出查看结果    cout<
<

转载于:https://my.oschina.net/u/923087/blog/279388

你可能感兴趣的文章
深度学习中常用的优化方法
查看>>
福利| HEXA邀你免费学习机器人开发
查看>>
使用DataV制作实时销售数据可视化大屏
查看>>
阿里云HTTPDNS使用教程
查看>>
计算机编程简史图
查看>>
Oracle 中实现随机抽取数据
查看>>
java关于安卓,苹果输入表情数据库处理
查看>>
var_export 与 var_dump的不同
查看>>
静态方法里不能使用$this标识调用静态方法
查看>>
建筑结构中的常见CAD技巧
查看>>
RunLoop
查看>>
java多线程 ThreadLocal
查看>>
maven depenencies 不见了
查看>>
关于android实现拖动旋转角度,调整布局参数的思路
查看>>
关于Java集合类迭代删除元素的一些坑
查看>>
注释那些事儿:前端代码质量系列文章(一)
查看>>
向代码致敬,寻找你的第83行
查看>>
【产品功能】配置网卡从此与关机无缘,弹性网卡支持热插拔功能
查看>>
UWP 绑定数据源异常 进入系统断点!global::System.Diagnostics.Debugger.Break();
查看>>
vue附件名字显示打印机的解决方案
查看>>