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

可以用手机做网站吗北京搜索引擎优化主管

可以用手机做网站吗,北京搜索引擎优化主管,台州网站建设蓝渊,关于网站建设项目创业计划书目录 string函数的构造 string赋值操作 string字符串拼接 string字符串查找和替换 string字符串比较 string字符存取 string插入与删除 string字串 string函数的构造 #include<iostream> #include<cstring> using namespace std; void test01() {string s…

目录

string函数的构造

string赋值操作

string字符串拼接

string字符串查找和替换

string字符串比较

string字符存取

string插入与删除

string字串


string函数的构造

#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string s1;//默认构造const char* str = "hello world";string s2(str);cout << "s2 = " << s2 << endl;string s3(s2);cout << "s3 = " << s3 << endl;string s4(10, 'a');cout << "s4 = " << s4 << endl;
}
int main()
{test01();system("pause");return 0;
}

string赋值操作

//author:至尊宝
//time:2024.5.5
#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string str1;str1 = "hello world";cout << "str1 = " << str1 << endl;string str2;str2 = str1;cout << "str2 = " << str2 << endl;string str3;str3 = 'a';cout << "str3 = " << str3 << endl;string str4;str4.assign("hello C++");cout << "str4 = " << str4 << endl;string str5;str5.assign("hello C++", 5);cout << "str5 = " << str5 << endl;string str6;str6.assign(str5);cout << "str6 = " << str6 << endl;string str7;str7.assign(10, 'b');cout << "str7 = " << str7 << endl;
}
int main()
{test01();system("pause");return 0;
}

string字符串拼接

//author:至尊宝
//time:2024.5.5
#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string str1 = "我";str1 += "爱玩游戏";cout << "str1 = " << str1 << endl;str1 += ':';cout << "str1 = " << str1 << endl;string str2 = "LOL DNF";str1 += str2;cout << "str1 = " << str1 << endl;string str3 = "I";str3.append(" love ");cout << "str3 = " << str3 << endl;str3.append("game abcde", 4);cout << "str3 = " << str3 << endl;/*str3.append(str2);cout << "str3 = " << str3 << endl;*///截取DNFstr3 += ' ';str3.append(str2, 4, 3);cout << "str3 = " << str3 << endl;
}
int main()
{test01();system("pause");return 0;
}

string字符串查找和替换

//author:至尊宝
//time:2024.5.5
#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string str1 = "abcdefg";int pos = str1.find("deo");if (pos == -1){cout << "未找到字符串" << endl;}else{cout << "找到字符串" << ",pos = " << pos << endl;}//rfindpos = str1.rfind("de");cout << "pos = " << pos << endl;//rfind从右往左查找,find从左往右查找
}
void test02()
{string str1 = "abcdefg";//从一号位置起3个字符替换为1111str1.replace(1, 3, "1111");cout << "str1 = " << str1 << endl;
}
int main()
{test02();system("pause");return 0;
}

string字符串比较

//author:至尊宝
//time:2024.5.5
#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string str1 = "xello";string str2 = "hello";if (str1.compare(str2) == 0){cout << "str1等于str2" << endl;}else if (str1.compare(str2) > 0){cout << "str1大于str2" << endl;}else{cout << "str1小于str2" << endl;}
}int main()
{test01();return 0;
}

string字符存取

//author:至尊宝
//time:2024.5.5
#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string str = "hello";cout << "str = " << str << endl;//单个字符//1.中括号for (int i = 0; i < str.size(); i++){cout << str[i];}cout << endl;//2.atfor (int i = 0; i < str.size(); i++){cout << str.at(i);}cout << endl;//修改单个str[0] = 'x';cout << "str = " << str<<endl;str.at(1) = 'x';cout << "str = " << str << endl;
}int main()
{test01();return 0;
}

string插入与删除

//author:至尊宝
//time:2024.5.5
#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string str = "hello";//插入str.insert(1, "111");cout << "str = " << str << endl;//删除str.erase(1, 3);cout << "str = " << str << endl;
}int main()
{test01();return 0;
}

string字串

//author:至尊宝
//time:2024.5.5
#include<iostream>
#include<cstring>
using namespace std;
void test01()
{string str = "abcdef";string str2 = str.substr(1, 3);cout << str2 << endl;
}
void test02()
{string email = "hello@sina.com";//从邮件地址中获取用户名信息int pos = email.find("@");string name = email.substr(0, pos);cout << name << endl;
}int main()
{test02();return 0;
}

http://www.yidumall.com/news/78850.html

相关文章:

  • 南开网站建设公司网站设计制作一条龙
  • 网站制作的软件湖北疫情最新消息
  • 网站做的和别人一样违法关键词优化排名查询
  • 帝国生成网站地图网络seo优化公司
  • 重新建网站需要转域名吗优化公司网站排名
  • 手机之家宁波seo网络推广报价
  • 境外网站 备案热词搜索排行榜
  • wordpress插件吧长沙seo推广优化
  • 找人做网站产生纠纷算诈骗吗西安seo服务外包
  • 中国建筑设计研究院济源新站seo关键词排名推广
  • 洛阳做网站价格企业营销策划有限公司
  • 上海网站建设 润合肥做网站哪家好
  • 珠海网站制作专业新网站 seo
  • 全能网站建设企业培训的目的和意义
  • 网站设计规划的一般流程什么网站可以发布广告
  • 定制网站案例百度问答平台入口
  • 网站整站优化网络营销题库案例题
  • 做免费的网站教程网络营销课程速成班
  • 主机屋 大网站搜索引擎广告的优缺点
  • 徐州做网站哈尔滨关键词优化报价
  • 环球资源网的网站特色搜索大全引擎地址
  • 承德做网站公司2024年2月疫情又开始了吗
  • 成都微信小程序制作湖南靠谱seo优化
  • 企业展厅公司哪家好娄底地seo
  • 太原便宜做网站的公司郑州seo优化推广
  • 南阳网站建设新闻百度收录网站入口
  • 临沂网站建设有哪些外链购买平台
  • 郑州哪些公司做网站建设培训总结怎么写
  • 郑州响应式网站制作永久8x的最新域名
  • 电商是什么?一般是干嘛的百度seo排名优化公司推荐