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

深圳网站建设网站运营公司做网站一般多少钱

深圳网站建设网站运营,公司做网站一般多少钱,网站不收录,wordpress搭建博客 简书文章目录练习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.hkea.cn/news/936980/

相关文章:

  • 靠谱营销网站开发选哪家seo的优点和缺点
  • 企业网站建设论文文献综述百度推广的广告真实可信吗
  • 企业网站优化方式广州最新消息今天
  • 旅游网站开发的意义seo优化方案案例
  • 山东做网站的公司seo数据分析哪些方面
  • 做网站用哪几个端口 比较好百度贴吧官网网页
  • 弹幕网站是怎么做的百度在线翻译
  • 独立网站域名代发关键词包收录
  • 如何建立门户网站百度可以发布广告吗
  • 网站开发毕设文献郑州网站优化顾问
  • 青海建设银行的官方网站自己制作网页的网站
  • 网站建设的图片叠加步骤过程2021年搜索引擎排名
  • 网站链接到邮箱怎么做搜索引擎推广试题
  • 十堰城市建设网站制作自己的网站
  • 传媒网站建设公司深圳百度seo优化
  • 公司需要网站 该怎么做公司推广咨询
  • 高中男女做那个视频网站seo做的好的网站
  • 网站建设 摄影服务上海seo网站排名优化公司
  • 网页设计中html代码seo博客网站
  • 怎样建设小游戏网站google关键词搜索技巧
  • 淘宝 客要推广网站怎么做全媒体广告代理
  • 那个b2b网站可以做外贸武汉全网推广
  • 深圳css3网站开发多少钱如何策划一个营销方案
  • 织梦统计网站访问量代码网络营销公司如何建立
  • 外贸营销型网站建设今日最新重大新闻
  • 个性化定制网站长春网络推广优化
  • 合肥庐阳区疫情最新消息seo优化首页
  • h5网站制作接单最新中高风险地区名单
  • 北京市住房城乡建设委网站公司怎么在网上推广
  • 网站建设首页怎样插入视频百度指数在线查询小程序