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

建设银行网站优点seo优化工具哪个好

建设银行网站优点,seo优化工具哪个好,自创网站,旅游网站建设的目的与意义是什么文章目录练习11.1练习11.2练习11.3练习11.4练习11.5练习11.6练习11.7练习11.8练习11.9练习11.10练习11.1 描述map 和 vector 的不同。 map 是关联容器, vector 是顺序容器。 练习11.2 分别给出最适合使用 list、vector、deque、map以及set的例子。 list&#xff1a…

文章目录

      • 练习11.1
      • 练习11.2
      • 练习11.3
      • 练习11.4
      • 练习11.5
      • 练习11.6
      • 练习11.7
      • 练习11.8
      • 练习11.9
      • 练习11.10

练习11.1

描述map 和 vector 的不同。

map 是关联容器, vector 是顺序容器。

练习11.2

分别给出最适合使用 list、vector、deque、map以及set的例子。

  • list:双向链表,适合频繁插入删除元素的场景。
  • vector:适合频繁访问元素的场景。
  • deque:双端队列,适合频繁在头尾插入删除元素的场景。
  • map:字典。
  • set:适合有序不重复的元素的场景。

练习11.3

编写你自己的单词计数程序。

#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <cctype>int main()
{std::map<std::string, std::size_t> word_count;std::string word;while (std::cin >> word)++word_count[word];for (const auto& elem : word_count)std::cout << elem.first << " : " << elem.second << "\n";return 0;
}

练习11.4

扩展你的程序,忽略大小写和标点。例如,“example.”、"example,"和"Example"应该递增相同的计数器。

#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <cctype>void word_count_pro(std::map<std::string, int>& m)
{std::string word;while (std::cin >> word){for (auto& ch : word) ch = tolower(ch);word.erase(std::remove_if(word.begin(), word.end(), ispunct),word.end());++m[word];}for (const auto& e : m) std::cout << e.first << " : " << e.second << "\n";
}int main()
{std::map<std::string, int> m;word_count_pro(m);return 0;
}

练习11.5

解释map和set的区别。你如何选择使用哪个?

map 是键值对,而 set 只有键没有值。当我需要存储键值对的时候使用 map,而只需要键的时候使用 set。

练习11.6

解释set和list 的区别。你如何选择使用哪个?

set 是有序不重复集合,底层实现是红黑树,而 list 是无序可重复集合,底层实现是链表。

练习11.7

定义一个map,关键字是家庭的姓,值是一个vector,保存家中孩子(们)的名。编写代码,实现添加新的家庭以及向已有家庭中添加新的孩子。

map<string, vector<string>> m;
for (string ln; cout << "Last name:\n", cin >> ln && ln != "@q";)for (string cn; cout << "|-Children's names:\n", cin >> cn && cn != "@q";)m[ln].push_back(cn);

练习11.8

编写一个程序,在一个vector而不是一个set中保存不重复的单词。使用set的优点是什么?

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>int main()
{std::vector<std::string> exclude = { "aa", "bb", "cc", "dd", "ee", "ff" };for (std::string word; std::cout << "Enter plz:\n", std::cin >> word;){auto is_excluded = std::binary_search(exclude.cbegin(), exclude.cend(), word);auto reply = is_excluded ? "excluded" : "not excluded";std::cout << reply << std::endl;}return 0;
}

set 的优点是集合本身的元素就是不重复。

练习11.9

定义一个map,将单词与一个行号的list关联,list中保存的是单词所出现的行号。

std::map<std::string, std::list<std::size_t>> m;

练习11.10

可以定义一个vector::iterator 到 int 的map吗?list::iterator 到 int 的map呢?对于两种情况,如果不能,解释为什么。

可以定义 vector<int>::iteratorint 的map,但是不能定义 list<int>::iteratorint 的map。因为map的键必须实现 < 操作,list 的迭代器不支持比较运算。

http://www.ritt.cn/news/3620.html

相关文章:

  • 网站地址验证失败网络营销策划书的主要内容
  • 广州市公司网站建设报价开发一个网站需要哪些技术
  • 代理商加盟网站自己想做个网站怎么做
  • 做视频网站空间要多大安卓优化大师破解版
  • 甘肃省建设工程造价信息网站关键词收录
  • wordpress管理媒体库插件seo网站排名优化案例
  • 网站建设 互诺科技做百度推广员赚钱吗
  • 网页设计公司建设网站百度发布
  • 重庆网站建设吧深圳抖音seo
  • 城口网站建设疫情最新资讯
  • 莆田网站制作站长工具app
  • 网上可以注册公司吗?都需要什么搜索引擎优化专员
  • dedecms手机网站模板泰安百度推广代理
  • 网站后台 英语app怎么开发出来的
  • 如何在eclipse上做网站商家推广平台有哪些
  • 做网站时的兼容问题百度推广营销怎么做
  • 怎样免费做网站视频讲解网络优化工程师主要负责什么工作
  • 电子商务是建网站域名注册商有哪些
  • 家居网站建设总结免费推广产品的网站
  • 成都哪家做网站的最好东莞网络营销
  • 宣传片拍摄脚本模板百度竞价seo排名
  • 佛山网站建设怎样做西安做网站公司
  • 个人微信公共号可以做微网站么sem竞价托管费用
  • javaee是做网站的深圳关键词优化
  • 网站建设白痴软件2022年最新十条新闻
  • 如何自学网站开发申请自己的网站
  • 微网站自助建设关键词首页优化
  • 网页综合设计丁的老头seo博客
  • cdn如何做网站统计图片搜索
  • 网络设计与集成在线优化seo