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

纯静态网站页面优化建设英文网站公司哪家好

纯静态网站页面优化,建设英文网站公司哪家好,在线流程图网站怎么做,大连项目备案网站一、什么是STL库 STL是“Standard Template Library”的缩写#xff0c;中文翻译为“标准模板库”。CSTL是一套功能强大的C模板类#xff0c;提供了通用的模板类和函数#xff0c;这些模板类和函数可以实现多种流行和常用的算法和数据结构#xff0c;如字符串操作、链表、队…一、什么是STL库 STL是“Standard Template Library”的缩写中文翻译为“标准模板库”。CSTL是一套功能强大的C模板类提供了通用的模板类和函数这些模板类和函数可以实现多种流行和常用的算法和数据结构如字符串操作、链表、队列、栈。 C标准模板库的核心包括以下三个组件 C标准模板库组件 组件描述容器顺序容器、关联容器容器是用来管理某一类对象的集合。C提供了各种不同类型的容器比如list, vector, map算法算法作用于容器提供了执行各种操作的方式包括对容器内容执行初始化、排序、搜索和转换等操作迭代器迭代器用于遍历对象集合的元素。类似于指针 二、STL的使用案例 1、可以去看官网的操作文档C中文参考手册 2、字符串模板类string 加上头文件#include string #include iostream #include string using namespace std;int main() {// 1、定义string s1(hello);string s2 world;cout s1 s1 endl;cout s2 s2 endl;// 2、赋值string s3 s1;string s4 s1 s2;string s5 s1;s5 s2;cout s3 s3 endl;cout s4 s4 endl;cout s5 s5 endl;// 3、at, 返回某个位置的引用string s6 s1;s6.at(0) p;cout s6 s6 endl;// 4、容量string s7 s1;cout s7.size() s7.size() endl;cout s7.capacity() s7.capacity() endl;cout s7.length() s7.length() endl;string s8 s1s1s1s1s1s1;cout s8.capacity1() s8.capacity() endl;// 5、第一个字符和最后一个字符cout s1第一个字符 s1.front() endl;cout s1最后一个字符 s1.back() endl;// 6、返回字符串类中字符串的指针地址const char* s_data s1.data();const char* s_str s1.c_str();cout s_data s_data endl;cout s_str s_str endl;// 7、插入string s9 s1;s9.insert(0, abcd);s9.insert(2, xyz);cout s9 s9 endl;// 8、[]s1[0] x;cout s1 s1 endl;// 9、追加string s10 s1;s10.push_back();s10.append(xyz);cout s10 s10 endl;// 10、查找int index s1.find(o);cout index index endl;// 11、比较string s12 hello;if(s12 hello){cout s12 hello endl;}// 12、迭代器string s13 hello world;cout s13 ;for(string::iterator it s13.begin(); it ! s13.end(); it){cout *it;}cout endl;// 13、数值转换string s14 123456;int value stoi(s14);cout value value endl;string s15 to_string(value);cout s15 s15 endl;// 14、 获取子串string s16 s13.substr(0, 5);cout s16 s16 endl;return 0; }3、顺序容器vector 加上头文件#include vector #include iostream #include vector using namespace std;struct node {char *name;void func(){} };int main() {vectorint myvector;// 1、插入myvector.push_back(10);myvector.push_back(20);myvector.push_back(30);myvector.push_back(40);myvector.push_back(50);// 2、迭代器遍历vectorint::iterator it;for(it myvector.begin(); it ! myvector.end(); it){cout *it \t;}cout endl;// 3、删除cout after del endl;myvector.pop_back();myvector.pop_back();// 4、容量cout size myvector.size() endl;// 5、使用数组形式遍历for(int i 0; i myvector.size(); i){cout myvector.at(i) \t;}cout endl;return 0; } 4、双向链表容器list 加上头文件#include list #include iostream #include listusing namespace std;class Student { private:string name;int age;int score; public:Student(string name string(), int age 18, int score 30){this-age age;this-name name;this-score score;}void show(){cout name \t age \t score endl;}friend bool cmp(const Student s1, const Student s2);string getName()const{return name;}void setAge(int Age){this-age Age;} };bool cmp(const Student s1, const Student s2) {return s1.score s2.score; }int main() {listStudent mylist;// 插到后面尾插mylist.push_back(*(new Student(zhang3, 20, 90)));mylist.push_back(*(new Student(zhang4, 21, 79)));// 插到前面头插mylist.push_front(*(new Student(zhang7, 19, 89)));mylist.push_front(*(new Student(zhang8, 25, 80)));// 遍历用迭代器cout before sort endl;listStudent::iterator it;for(it mylist.begin(); it ! mylist.end(); it){it-show();}// 排序mylist.sort(cmp); // cmp函数是自定义的排序内容cout after sort endl;for(it mylist.begin(); it ! mylist.end(); it){it-show();}// 删除it mylist.begin();it mylist.erase(it);cout after del first endl;for(it mylist.begin(); it ! mylist.end(); it){it-show();}// 查找和修改for(it mylist.begin(); it ! mylist.end(); it){if(it-getName() zhang7){cout find zhang7 endl;it-setAge(50);}}for(it mylist.begin(); it ! mylist.end(); it){it-show();}return 0; } 5、栈容器stack #include iostream #include stackusing namespace std;int main() {stackint mystack;// 入栈mystack.push(10);mystack.push(20);mystack.push(30);mystack.push(40);mystack.push(50);// 栈的元素个数cout size: mystack.size() endl;// 栈没有空就一直出栈int data;while(!mystack.empty()){data mystack.top(); // 出栈前需要先获取栈顶元素mystack.pop();cout data \t;}cout endl;return 0; }6、队列容器queue #include iostream #include queueusing namespace std;int main() {queueint myqueue;// 入队myqueue.push(10);myqueue.push(20);myqueue.push(30);myqueue.push(40);myqueue.push(50);// 获取队列的元素个数 cout size: myqueue.size() endl;// 队头元素cout front: myqueue.front() endl;// 队尾元素cout back: myqueue.back() endl;// 遍历int data;while(!myqueue.empty()){data myqueue.front();myqueue.pop(); // 从队头出队的先要保留队头元素cout data \t;}cout endl;return 0; }7、关联容器map  #include iostream #include mapusing namespace std;int main() {// map是以键值对的方式存放数据// 第一个类型是键第二类型是值其中键不一定是整形可以是字符串mapint, string mymap1;// 插入或者访问键不一定要连续mymap1[1] a;mymap1[2] b;mymap1[10] c;mymap1[100] d;for(mapint, string::iterator it mymap1.begin(); it ! mymap1.end(); it){// 键用first来访问值用second来访问// 不允许使用cout it endl; 来访问cout it-first it-second endl;}// 不一定要连续mapstring, string mymap2;mymap2[zhang3] 123;mymap2[li4] 124;mymap2[wang5] 45;mymap2[hong6] 4543;for(mapstring, string::iterator it mymap2.begin(); it ! mymap2.end(); it){// 键用first来访问值用second来访问cout it-first it-second endl;}return 0; }三、总结 以上就是STL库中常用的容器以及对应的操作使用时需要添加对应的头文件名同时不同容器之间的有些相同操作是同名的具体更多细节可以去看看官网的中文参考手册。
http://www.dnsts.com.cn/news/235125.html

相关文章:

  • 山西省建设厅政务中心网站国内广告公司排行
  • 嘉兴品牌网站设计如何用dw修改wordpress的首页
  • 制作app需要学哪些东西专业知识宁波seo网络推广推荐公众号
  • 网站引流怎么做电商平台站内推广有哪些
  • 安徽万振建设集团网站石家庄网站建设加王道下拉
  • 网站录入商城网站前端更新商品天天做吗
  • 数据库设计对网站开发的影响专业邯郸网站建设
  • 做网站多少钱大概韩国网站模板下载地址
  • 大连网站建设哪家公司好长沙高端网站建设
  • 山西百度网站建设快速app开发平台
  • 做rom的网站wordpress侧栏跟随
  • 网站模版html网站托管服务商
  • 肇庆网站建设咨询网站建设网站建设哪里有
  • 云南建设招标网站长沙网络公司app
  • 自建网站平台代理网页在线
  • wordpress中文网站模板个人网站电商怎么做
  • 郑州付费系统网站开发建设网站版权问题
  • 网络站点推广的方法有哪些那种投票网站里面怎么做
  • 网站加速 wordpress上海网络推广公司网站
  • 百度开放云做网站wordpress 后台 字数统计
  • 怎么样让百度收录网站photoshop下载手机版
  • 一个网站同时做百度和360 百度商桥都可以接收客户信息吗公司注册在上海的好处
  • 让你有做黑客感觉的网站做公众号用什么网站吗
  • 网站导航栏特效网站建设方案书 内容管理制度
  • 无代码建站软件网站降权查下
  • 网站建设的风格设置中国建设银行网站 个人
  • 成绩查询系统网站开发四川seo哪家好
  • 网站开发数据库技术贵州住房建设厅官网查询
  • 无锡市住房和城乡建设局网站女生学前端还是后端
  • 普洱在百度上做网站的wordpress getterms