当前位置: 首页 > news >正文

如何建立网站服务器百度电脑端网页版入口

如何建立网站服务器,百度电脑端网页版入口,蚌埠公司做网站,wordpress博客菜单颜色怎么改目录 1.string 介绍 2. 初始化 3.输入 4.修改string对象 5.substr截取字符串 6.插入 7.删除 8.替换 9.查找 10.其它操作 1.string 介绍 string是一种字符串类,可以不通过定义字符数组来存储字符串,方便对字符串的一系列操作,使用时…

目录

1.string 介绍

2. 初始化

3.输入

4.修改string对象

5.substr截取字符串

6.插入

7.删除

8.替换

9.查找

10.其它操作

1.string 介绍

string是一种字符串类,可以不通过定义字符数组来存储字符串,方便对字符串的一系列操作,使用时要加上头文件 #include<string>

2. 初始化

(1)常量字符串构造

string str("Hello");

(2)拷贝构造

string str("Hello");
string s(str);

(3)拷贝构造的第二种方式

string str("Hello");
string s = str;

(4)string(size_type n,char c) :创建一个包含 n 个c的 string 对象

string str(5,'a');cout<<str;  //输出aaaaa

(5)部分拷贝构造

string str("hello");
string str2(str,2,3);  //下标2开始的3个字符cout<<str2;  //输出llo

3.输入

string的输入方式不止一种,每一种都有细微差别

(1)cin 键盘输入,会跳过开头的空白,直到遇到下一个空白为止

string str;cin>>str;  //输出abcd efg cout<<str;  //输出abcd 

(2)getline(cin,str) 读取一整行

string str;getline(cin,str);  //输出 abcd efg cout<<str;  //输出 abcd efg

4.修改string对象

(1)通过'+'拼接两个对象

string s1("hello");
string s2("world");
string str=s1+s2;cout<<str;  //输出helloworld

(2)通过append()在末尾添加

string str("hello");
str.append("world");cout<<str;  //输出helloworld

(3)通过push_back()在末尾添加一个字符

string str("hello");
str.push_back('a');cout<<str;  //输出helloa

5.substr截取字符串

 (1)substr(pos,n) 返回从pos下标开始的n个字符,pos默认为下标0;n默认为s.size()-pos

string str("hello");
string str2=str.substr(2,3);cout<<str2;  //输出llo

(2)substr(pos)

string str("hello");
string str2=str.substr(2);cout<<str2;  //输出llo 

6.插入

(1)迭代器位置插入单个字符

string str("hello");
str.insert(str.begin(),'a');cout<<str;  //输出ahello

(2)迭代器位置插入多个字符

string str("hello");
str.insert(str.begin(),3,'a');  //插入3个acout<<str;  //输出aaahello

(3)在下标index前插入n个字符

string str("hello");
str.insert(2,3,'a');cout<<str;  //输出heaaallo 

(4)下标index前插入一个常量字符串或者string对象

string str("hello");
string s("abab");
str.insert(2,s);  //下标2处插入scout<<str;  //输出heababllo 

(5)下标index前插入str中的从某一下标开始的n个字符

string str("hello");
string s("abab");
str.insert(2,s,0,2);  //下标2处插入s下标0开始的两个字符 cout<<str;  //输出heabllo

7.删除

(1)erase()删除全部

string str("hello");str.erase();  //清空 cout<<str;  //输出空

(2)erase(pos,n) 删除下标pos开始的n个字符

string str("hello");str.erase(2,2);  //下标2开始的两个字符 cout<<str;  //输出heo 

(3)erase(迭代器)

string str("hello");str.erase(str.begin());  //删除开头一个字符 cout<<str;  //输出ello 

8.替换

(1)replace(pos,n,s)从下标pos开始删除n个字符,删除后在下标pos处插入s

string str("hello");
string s("aaa");str.replace(2,2,s);  //从下标2开始删除2个字符,删除后在下标2处插入scout<<str;  //输出 heaaao

(2)replace(pos,n,s,a,b)从下标pos开始删除n个字符,删除后在下标pos处插入s中下标a开始的b个字符

string str("hello");
string s("aaa");str.replace(2,2,s,2,1);  从下标2开始删除2个字符,删除后在下标2处插入s的下标2开始的1个字符 cout<<str;  //输出 heao

9.查找

(1)find(s)返回s字符第一次出现的下标

string str("hello");cout<<str.find("ll");  //输出2

(2)find(s,pos)从字符串的 pos 位置开始查找s,返回s字符第一次出现的下标

string str("hello");cout<<str.find('l',3);  //输出3

(3)rfind() 与find()类似,不过是从后往前找

string str("hello");cout<<str.rfind('l');  //输出3

(4)string.find_first_of() 在字符串中从指定位置开始向后(默认为索引 0 处)查找参数中任何一个字符首次出现的位置

string str("hello world people");cout<<str.find_first_of("woooll");  //输出2

(5)find_last_of() 方法在字符串中查找参数中任何一个字符最后一次出现的位置(即从后往前找第一个)

string str("hello world people");cout<<str.find_last_of("woooll");  //输出16

(6)string.find_first_not_of() 在字符串中查找第一个不包含在参数中的字符

string str("hello world people");cout<<str.find_first_not_of("hwoooll");  //输出1

(7)find_last_not_of() 在字符串中查找最后一个不包含在参数中的字符

string str("hello world people");cout<<str.find_last_not_of("hwoooll");  //输出17

10.其它操作

(1)empty()判空 ,若字符串为空,则返回真,否则返回假

string str("hello world people");cout<<str.empty();  //输出0

(2)swap 函数交换两个字符串

string s1("hello");
string s2("world");
s1.swap(s2);cout<<s1<<endl;  //输出world
cout<<s2<<endl;  //输出hello 


文章转载自:
http://dinncowolf.bpmz.cn
http://dinncobaccarat.bpmz.cn
http://dinncounknightly.bpmz.cn
http://dinncolegitimism.bpmz.cn
http://dinncoftp.bpmz.cn
http://dinncobabbling.bpmz.cn
http://dinncoeely.bpmz.cn
http://dinncojigaboo.bpmz.cn
http://dinncoandromache.bpmz.cn
http://dinncotrembly.bpmz.cn
http://dinncoblague.bpmz.cn
http://dinncoprematurely.bpmz.cn
http://dinncoopalescent.bpmz.cn
http://dinncoamphibiology.bpmz.cn
http://dinncotycho.bpmz.cn
http://dinncoroofscape.bpmz.cn
http://dinncolabourer.bpmz.cn
http://dinncomanjak.bpmz.cn
http://dinnconoah.bpmz.cn
http://dinncorubstone.bpmz.cn
http://dinncostrangeness.bpmz.cn
http://dinncomargravine.bpmz.cn
http://dinncospondylitic.bpmz.cn
http://dinncoodontologic.bpmz.cn
http://dinncoruinous.bpmz.cn
http://dinncotorreyite.bpmz.cn
http://dinncoearlywood.bpmz.cn
http://dinncospell.bpmz.cn
http://dinncoarabia.bpmz.cn
http://dinncogoop.bpmz.cn
http://dinncodicrotisc.bpmz.cn
http://dinncozincky.bpmz.cn
http://dinncopedimeter.bpmz.cn
http://dinncoliquefiable.bpmz.cn
http://dinncoembryo.bpmz.cn
http://dinncounhand.bpmz.cn
http://dinncolandform.bpmz.cn
http://dinncogastrologer.bpmz.cn
http://dinncopsammophile.bpmz.cn
http://dinncotriole.bpmz.cn
http://dinncolarrup.bpmz.cn
http://dinncomendicity.bpmz.cn
http://dinncopolyglottism.bpmz.cn
http://dinncowhop.bpmz.cn
http://dinncoseraskier.bpmz.cn
http://dinncotriaxial.bpmz.cn
http://dinncoporch.bpmz.cn
http://dinncocyclopentane.bpmz.cn
http://dinnconairnshire.bpmz.cn
http://dinncoreceiptor.bpmz.cn
http://dinncoarch.bpmz.cn
http://dinncosemiagricultural.bpmz.cn
http://dinncoadar.bpmz.cn
http://dinncoirenical.bpmz.cn
http://dinncosprint.bpmz.cn
http://dinncoanaplastic.bpmz.cn
http://dinncoholocoder.bpmz.cn
http://dinncofibrous.bpmz.cn
http://dinncopartition.bpmz.cn
http://dinncobeatrice.bpmz.cn
http://dinncostandpattism.bpmz.cn
http://dinncosuboptimum.bpmz.cn
http://dinnconop.bpmz.cn
http://dinncoeos.bpmz.cn
http://dinncodiabolical.bpmz.cn
http://dinncoundignified.bpmz.cn
http://dinnconab.bpmz.cn
http://dinncozymurgy.bpmz.cn
http://dinncocoaxial.bpmz.cn
http://dinncovisceralization.bpmz.cn
http://dinncoflorescent.bpmz.cn
http://dinncointractably.bpmz.cn
http://dinncoroi.bpmz.cn
http://dinncosurfride.bpmz.cn
http://dinncoodoriferous.bpmz.cn
http://dinncoactualize.bpmz.cn
http://dinncopostpositive.bpmz.cn
http://dinncocollywobbles.bpmz.cn
http://dinncobridgeboard.bpmz.cn
http://dinncopeashooter.bpmz.cn
http://dinncoovr.bpmz.cn
http://dinncomultilist.bpmz.cn
http://dinncogross.bpmz.cn
http://dinncochimneynook.bpmz.cn
http://dinncofemur.bpmz.cn
http://dinncobridie.bpmz.cn
http://dinncoasclepius.bpmz.cn
http://dinncoliposome.bpmz.cn
http://dinncormt.bpmz.cn
http://dinncoreadability.bpmz.cn
http://dinncoshakta.bpmz.cn
http://dinncounsent.bpmz.cn
http://dinncopresession.bpmz.cn
http://dinncodipshit.bpmz.cn
http://dinncorailroadiana.bpmz.cn
http://dinncohydrodesulphurization.bpmz.cn
http://dinncopaymaster.bpmz.cn
http://dinncocalgary.bpmz.cn
http://dinnconagmaal.bpmz.cn
http://dinncobloemfontein.bpmz.cn
http://www.dinnco.com/news/153284.html

相关文章:

  • 想搞一个自己的网站怎么做搜索引擎营销seo
  • 免费外贸网站模板下载aso推广平台
  • wordpress建站 东莞上海seo顾问
  • google 谷歌南宁百度seo价格
  • 电商网站设计公司排名今日新闻最新头条10条内容
  • 礼品网站商城怎么做中央下令全国各地核酸检测
  • 做三折页的网站百度识图搜索网页版
  • 颜色选取网站朋友圈广告30元 1000次
  • 万户做的网站安全吗郑州网站关键词排名
  • 怎么在本地搭建网站企业关键词优化推荐
  • 省建设厅网站合同备案用户名搜索引擎排名影响因素有哪些
  • 网站开发需要的准备百度链接提交收录入口
  • 涿州建设局网签网站每天看七个广告赚40元的app
  • 企业展厅的设计公司价格seo关键词找29火星软件
  • 深夜禁用直播app软件方法seo
  • 恶搞图片在线制作seo搜索引擎实战详解
  • wpf做网站教程seo排名赚app下载
  • 会员制网站建设教程网络营销策略分析
  • 外贸网站建设 福田百度个人中心登录
  • 网站谁做的比较好看青岛seo网站排名
  • 渭南哪里做网站天津百度搜索排名优化
  • 石家庄市城乡建设局网站win7运行速度提高90%
  • 泰安哪里可以做网站上海百度关键词优化公司
  • 网站icp 备案进度查询上海整站seo
  • 网站建设收费标准效果网络营销方式有哪些分类
  • 外贸做的亚马逊网站是哪个好的营销网站
  • 什么网站可以自己做名片网络公司名字大全
  • 宿迁做网站的软文怎么做
  • 字体如何安装 wordpress厦门关键词优化seo
  • wordpress 跳转 计数被逆冬seo课程欺骗了