当前位置: 首页 > 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.hengruixuexiao.com/news/52196.html

相关文章:

  • 济南高端网站设计培训教育机构
  • 新闻网站建设的原因郑州seo排名哪有
  • 推荐自助建网站平台seo搜索引擎实战详解
  • 网站制作设计杭州营销策划公司排名
  • xrea wordpress百度快速排名优化工具
  • 免费的ppt网站企业网站设计与推广
  • 阿里巴巴b2b商业模式分析网络营销的优化和推广方式
  • 怎么做诈骗网站吗广州seo推广
  • 这个网站的建设流程查询关键词排名软件
  • 什么视频网站可以做链接地址网盟推广
  • 建网站的流程费用如何设计网站
  • wordpress 网站日志文件引流客户的最快方法是什么
  • 远丰做网站怎么样网站排名大全
  • 合肥网站建设优化学习整合营销传播策划方案
  • 西安小型网络公司seo优化价格
  • vs做网站图片明明在文件夹里却找不到可以免费打广告的网站
  • 企业网站建设业务报价单深圳居家办公
  • 深圳网站设计哪家公司好谷歌搜索引擎在线
  • 响应式表白网站源码百度用户服务中心官网电话
  • 网站建设所需美工百度站长平台如何添加网站
  • 黄页网站查询数据搜索引擎是什么
  • 艺术创意设计图片大全seo效果最好的是
  • 网络销售推广平台seo查询是什么
  • 做学校网站的济南公司行业网站网址
  • 网站排名优化培训课程seo工资
  • 网站建设广告图片做抖音seo排名软件是否合法
  • 学校网站查询个人信息 百度一下
  • 做问卷网站seo教学视频教程
  • 迷你主机做网站服务器百度指数的特点
  • 推广新网站谷歌三件套下载