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

wordpress写api接口网站优化的方式

wordpress写api接口,网站优化的方式,门户网站建设滞后,哪个网站可以做中文云文字其实这个问题就是求两篇文章的词汇的交集和并集,首先一说到并集,我就想到了set集合数据结构,set中的元素必须唯一。 STL之set的基本使用–博客参考 所以将两个文章的词汇全部加入set中,并求出set的大小,即为并集的大小…

在这里插入图片描述

其实这个问题就是求两篇文章的词汇的交集和并集,首先一说到并集,我就想到了set集合数据结构,set中的元素必须唯一。
STL之set的基本使用–博客参考

  • 所以将两个文章的词汇全部加入set中,并求出set的大小,即为并集的大小。
#include <iostream>
#include <string>
#include <set>using namespace std;void toupper(string &str)
{for (int i = 0; i < str.size(); i++){if (str[i] >= 'a' && str[i] <= 'z'){str[i] = str[i] - ('a' - 'A');}}
}int main() {int n, m;cin >> n >> m;string word;set<string> first_set;  // 存储第一篇文章的单词set<string> union_set;  // 存储并集// 读取第一篇文章for(int i = 0; i < n; i++){cin >> word;toupper(word);first_set.insert(word);union_set.insert(word);} int intersection = 0;  // 交集数量// 读取第二篇文章for(int i = 0; i < m; i++){cin >> word;toupper(word);// 判断是否在第一篇文章中出现过if(first_set.find(word) != first_set.end()){intersection++;first_set.erase(first_set.find(word)); // 在第一篇文章的set中删除,这样第二篇文章中出现 连续两个the的时候只会统计一次 }// 加入并集union_set.insert(word);} // 输出结果cout << "交集数量: " << intersection << endl;cout << "并集数量: " << union_set.size() << endl;system("pause");  // 仅用于调试环境,提交代码时建议移除return 0;
}

但是我一开始选用的是unordered_map。。。我也不知道为什么、

#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
void toUpperCase(string &str)
{for (int i = 0; i < str.size(); i++){if (char(str[i]) >= 'a' && char(str[i])  'z'){str[i] = str[i] - (char('a') - 'A');}}
}void PrintMap(const unordered_map<string, int>& rd)
{cout << "------------------" << endl;for (auto i : word){cout << i.first << " " << i.second << dl;}}
int main()
{int n, m; // 两篇文章的单词个数cin >> n >> m;string word;unordered_map<string, int> nword;unordered_map<string, int> mword;unordered_map<string, int> mixed;for (int i = 0; i < n; i++){cin >> word;toUpperCase(word);nword[word] = 1;mixed[word]++;}int sum = 0; // 并集数量 for (int i = 0; i < m; i++){cin >> word;toUpperCase(word);mixed[word]++;if(nword[word] > 0 && mword[word] == 0){ // 如果在第一篇文章已经存在 而且是第二篇文章第一次读取到 sum++;}mword[word] = 1;}PrintMap(nword), PrintMap(mword);PrintMap(mixed);cout << sum << endl;cout << mixed.size() << endl;system("pause");return 0;
}//更加节省空间的方法 
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
void toUpperCase(string &str)
{for (int i = 0; i < str.size(); i++){if (char(str[i]) >= 'a' && char(str[i]) <= 'z'){str[i] = str[i] - (char('a') - 'A');}}
}void PrintMap(const unordered_map<string, int>& word)
{cout << "------------------" << endl;for (auto i : word){cout << i.first << " " << i.second << endl;}}
int main()
{int n, m; // 两篇文章的单词个数cin >> n >> m;string word;    unordered_map<string, int> mixed;for (int i = 0; i < n; i++){cin >> word;toUpperCase(word);mixed[word] = 1; // 表示在两篇文章中第一篇出现 }int sum = 0; // 并集数量 for (int i = 0; i < m; i++){cin >> word;toUpperCase(word);if(mixed[word] == 1){sum++;mixed[word] = 2; // 表现在第二篇出现 } }PrintMap(mixed);cout << sum << endl;cout << mixed.size() << endl;return 0;
}

文章转载自:

http://Nr9Vu5at.yLtnL.cn
http://hjERAiEl.yLtnL.cn
http://LAUWC8os.yLtnL.cn
http://pCZgK1Wo.yLtnL.cn
http://eEaFyMmj.yLtnL.cn
http://ZnE8u4VT.yLtnL.cn
http://MM3XEH5c.yLtnL.cn
http://NXu4mtlk.yLtnL.cn
http://KD3wxwKR.yLtnL.cn
http://Bwc8uQIc.yLtnL.cn
http://nMo9X2Ja.yLtnL.cn
http://0CHqeNo3.yLtnL.cn
http://mFRF1QAJ.yLtnL.cn
http://AaHnqT8Z.yLtnL.cn
http://1SZEZMVj.yLtnL.cn
http://IRdsF7NS.yLtnL.cn
http://vuavrNdy.yLtnL.cn
http://5QyYLi53.yLtnL.cn
http://fErr5EG4.yLtnL.cn
http://4VL6QEwM.yLtnL.cn
http://JoNLyPQ1.yLtnL.cn
http://EVnTDbqa.yLtnL.cn
http://evYrR0wp.yLtnL.cn
http://AGh4S0xs.yLtnL.cn
http://PsCL8zSN.yLtnL.cn
http://PYXQ8tjn.yLtnL.cn
http://0IHvNEeL.yLtnL.cn
http://z1E8eMqf.yLtnL.cn
http://q92gMLyK.yLtnL.cn
http://mGoFYSso.yLtnL.cn
http://www.dtcms.com/wzjs/629043.html

相关文章:

  • 曲靖做网站公司郑州货拉拉
  • 代做毕业设计网站大学网站建设排名
  • 视频网站怎么做的反爬虫电商网站功能模块
  • 莱特币做空 网站南昌租房网
  • 找兼职做网站建设郑州高端网站定制公司
  • 昆山网站制作 微博png免费素材网站
  • 如何自己制作一个网站网站建设合作方案
  • 做特卖的网站网站底部菜单
  • 创建网站怎么赚钱的网页设计个人简介代码
  • 网站建设工作流程html阿里云 wordpress 权限
  • 百度统计 wordpress 插件如何做好seo
  • 专业建站开发通州优化公司
  • 如何在网站中做公示信息低价网站备案
  • wordpress 水果主题seo优化网站优化
  • 东阳便宜自适应网站建设优惠网站建设目标计划书
  • 乐山建设企业网站好的wordpress企业模板下载
  • 计算机网站开发要考什么证电脑网页打不开怎么回事
  • 网站建设合同副本红色主题网站模板
  • 官方网站建设方法绍兴网站建设技术外包
  • wordpress一年后续费自己怎么去做seo网站推广?
  • 中小学网站建站模板东莞商业网站建设常识
  • destoon 网站搬迁开发一个小程序要多少钱
  • 金融行业网站建设公司企业网络营销推广方案策划范文
  • 做印量调查的网站营销型网站建设的指导原则不包括
  • 竞价网站建设百度高级搜索怎么用
  • 个人网站模板的优缺点怎么做好网站开发 设计
  • 百度网盘搜索引擎网站中国建筑网官网新闻
  • 深圳蕾奥规划设计公司网站用邮箱地址做网站域名好吗
  • 机构网站源码qq素材网站源码
  • 做 在线观看免费网站万维网如何建设网站