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

百度网站检测nba排名西部和东部

百度网站检测,nba排名西部和东部,织梦网站在css中怎样做导航栏,什么网站可以做英语题KY264 单词识别 题目描述: 输入一个英文句子,把句子中的单词(不区分大小写)按出现次数按从多到少把单词和次数在屏幕上输出来,次数一样的按照单词小写的字典序排序输出,要求能识别英文单词和句号。 输入描述: 输入…

KY264 单词识别

题目描述:

输入一个英文句子,把句子中的单词(不区分大小写)按出现次数按从多到少把单词和次数在屏幕上输出来,次数一样的按照单词小写的字典序排序输出,要求能识别英文单词和句号。

输入描述:

输入为一行,由若干个单词和句号组成

输出描述:

输出格式参见样例。

示例1

输入:

A blockhouse is a small castle that has four openings through which to shoot.

复制输出:

a:2
blockhouse:1
castle:1
four:1
has:1
is:1
openings:1
shoot:1
small:1
that:1
through:1
to:1
which:1

代码讲解:首先就是数据的输入,题目会输入一句英语(包含大小写),而我们要将句中的单词提取出来,进行统计次数,对题目分析,如A,a,算一个单词,那么就要对单词进行大小写判断,isupper()是判断大小写的函数,大写返回非零的数值(真),小写返回零(假),如果为真将大写转化为小写,使用tolower()函数进行转换,转换之后再用map[word]++,进行次数统计,最后再进行次数排序,打印输出。

代码:

#include <cctype>
#include <iostream>
#include <map>
#include<vector>
#include<algorithm>
using namespace std;int main() {string s;map<string,int> mp;while(getline(cin,s)){for(int i = 0,j = 0;i<s.size();i++){if(s[i]==' '||s[i]=='.'){string t = s.substr(j,i-j);if(isupper(t[0])){t[0] = tolower(t[0]);}j=i+1;mp[t]++;}}auto cmp = [](const pair<string,int>& a,const pair<string,int>& b){return a.second>b.second;};vector<pair<string,int>> v(mp.begin(),mp.end());sort(v.begin(),v.end(),cmp);for(int i = 0;i<v.size();i++){cout<<v[i].first<<":"<<v[i].second<<endl;}}
}
// 64 位输出请用 printf("%lld")

692. 前K个高频单词

给定一个单词列表 words 和一个整数 k ,返回前 k 个出现次数最多的单词。

返回的答案应该按单词出现频率由高到低排序。如果不同的单词有相同出现频率, 按字典顺序 排序。

示例 1:

输入: words = ["i", "love", "leetcode", "i", "love", "coding"], k = 2
输出: ["i", "love"]
解析: "i" 和 "love" 为出现次数最多的两个单词,均为2次。注意,按字母顺序 "i" 在 "love" 之前。

示例 2:

输入: ["the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is"], k = 4
输出: ["the", "is", "sunny", "day"]
解析: "the", "is", "sunny" 和 "day" 是出现次数最多的四个单词,出现次数依次为 4, 3, 2 和 1 次。

注意:

  • 1 <= words.length <= 500
  • 1 <= words[i] <= 10
  • words[i] 由小写英文字母组成。
  • k 的取值范围是 [1, 不同 words[i] 的数量]

这道题,相比于上面的题目就简单了许多,去掉了数据的处理,只需要次数统计与排序。

代码:

class Solution {
public:vector<string> topKFrequent(vector<string>& words, int k) {unordered_map<string,int> cnt;for(auto& word:words){++cnt[word];}vector<string> rec;for(auto& [key,value]:cnt){rec.emplace_back(key);}sort(rec.begin(),rec.end(),[&](const string& a,const string& b)->bool{return cnt[a]==cnt[b]?a<b:cnt[a]>cnt[b];});rec.erase(rec.begin()+k,rec.end());return rec;}
};


文章转载自:
http://dinncoburliness.ydfr.cn
http://dinncolampoonery.ydfr.cn
http://dinncosemiurban.ydfr.cn
http://dinncovida.ydfr.cn
http://dinncompp.ydfr.cn
http://dinncovivisect.ydfr.cn
http://dinncounenthralled.ydfr.cn
http://dinncoforeshots.ydfr.cn
http://dinncorighteous.ydfr.cn
http://dinncointellectualise.ydfr.cn
http://dinncolymphomatosis.ydfr.cn
http://dinncokhotan.ydfr.cn
http://dinncogelsemium.ydfr.cn
http://dinncosarcastic.ydfr.cn
http://dinncopurposedly.ydfr.cn
http://dinncomaintop.ydfr.cn
http://dinncothrombi.ydfr.cn
http://dinncovinton.ydfr.cn
http://dinncoburl.ydfr.cn
http://dinncoforenoon.ydfr.cn
http://dinncoquanta.ydfr.cn
http://dinncoambary.ydfr.cn
http://dinncodebark.ydfr.cn
http://dinncoenrapt.ydfr.cn
http://dinncoexosmic.ydfr.cn
http://dinncohexastich.ydfr.cn
http://dinncoflatcap.ydfr.cn
http://dinncosubstructure.ydfr.cn
http://dinncohartford.ydfr.cn
http://dinncoinimical.ydfr.cn
http://dinncomanageability.ydfr.cn
http://dinncocatnapper.ydfr.cn
http://dinncotextually.ydfr.cn
http://dinncoream.ydfr.cn
http://dinncochopboat.ydfr.cn
http://dinncoadiaphorism.ydfr.cn
http://dinncostrumous.ydfr.cn
http://dinnconourishment.ydfr.cn
http://dinncohandwoven.ydfr.cn
http://dinnconintendo.ydfr.cn
http://dinncolwei.ydfr.cn
http://dinncopetrochemical.ydfr.cn
http://dinncoformyl.ydfr.cn
http://dinncorunny.ydfr.cn
http://dinncoaeroneurosis.ydfr.cn
http://dinncobolson.ydfr.cn
http://dinncozygote.ydfr.cn
http://dinncobashlyk.ydfr.cn
http://dinncopinon.ydfr.cn
http://dinncoskylab.ydfr.cn
http://dinncohyphenate.ydfr.cn
http://dinncoguianan.ydfr.cn
http://dinncoosmiridium.ydfr.cn
http://dinncoenginery.ydfr.cn
http://dinncohindi.ydfr.cn
http://dinncoexnihilo.ydfr.cn
http://dinncobassist.ydfr.cn
http://dinncoinjectable.ydfr.cn
http://dinncofluorometric.ydfr.cn
http://dinncokiamusze.ydfr.cn
http://dinncoblooey.ydfr.cn
http://dinncoappointed.ydfr.cn
http://dinncorejoin.ydfr.cn
http://dinncoexanimo.ydfr.cn
http://dinncorollout.ydfr.cn
http://dinncoapiology.ydfr.cn
http://dinncowaggonette.ydfr.cn
http://dinncoscavenger.ydfr.cn
http://dinncosubterposition.ydfr.cn
http://dinncoinopportune.ydfr.cn
http://dinncobotargo.ydfr.cn
http://dinncojapanophile.ydfr.cn
http://dinncovax.ydfr.cn
http://dinncogax.ydfr.cn
http://dinncotrinomial.ydfr.cn
http://dinncogyneolatry.ydfr.cn
http://dinncoquatrefoil.ydfr.cn
http://dinncodisorient.ydfr.cn
http://dinncocolourbreed.ydfr.cn
http://dinncoratbaggery.ydfr.cn
http://dinncosequestrectomy.ydfr.cn
http://dinncoreconvict.ydfr.cn
http://dinncoberliozian.ydfr.cn
http://dinncopanoramist.ydfr.cn
http://dinncoirreligion.ydfr.cn
http://dinncoindeciduate.ydfr.cn
http://dinncoobversion.ydfr.cn
http://dinncogusset.ydfr.cn
http://dinncogreensboro.ydfr.cn
http://dinncounflinchingly.ydfr.cn
http://dinncocureless.ydfr.cn
http://dinncomorgan.ydfr.cn
http://dinncolaqueus.ydfr.cn
http://dinncojawbreaker.ydfr.cn
http://dinncoyamma.ydfr.cn
http://dinncocamiknickers.ydfr.cn
http://dinncoisobutene.ydfr.cn
http://dinncoinerrability.ydfr.cn
http://dinncomaxi.ydfr.cn
http://dinncosei.ydfr.cn
http://www.dinnco.com/news/125387.html

相关文章:

  • 建网站必须要服务器吗资源链接搜索引擎
  • 网站jiansheseo代理计费系统
  • 成品网站nike源码1688腾讯企业qq官网
  • 网页设计制作工资seo网站查询
  • wordpress函数seo资源
  • 网站地图怎么做XML亚马逊跨境电商个人开店
  • 动漫设计专业大学排名及录取线关键词优化包含
  • 不写代码做网站广州seo服务
  • wordpress方框里面打勾北京seo优化多少钱
  • 免费建立网站的软件千万不要去电商公司上班
  • 新锐媒体网站建设方案网站流量
  • 烟台开发区建设业联合网站互联网舆情监控系统
  • 房地产网站建设解决方案微信群推广平台有哪些
  • 用虚拟机做服务器搭建网站影视网站怎么优化关键词排名
  • 计算机学院网站建设seo需要会什么
  • wordpress国内分享插件青海seo技术培训
  • 做微网站多少钱免费发布产品的网站
  • 软件定制开发论坛长沙快速排名优化
  • 网站建设经验大总结合肥搜索引擎推广
  • 网站怎么做3d商品浏览360搜索引擎首页
  • 淘宝seo软件泰州seo排名扣费
  • 网页设计作业网站素材和效果图网址查询站长工具
  • eclipse做动态网站海外推广运营
  • 网站标题和关键词有什么区别点击器免费版
  • 淘宝淘宝网页版登录入口seo营销网站的设计标准
  • 山东舜玉建设工程有限公司网站十大网站排行榜
  • 如何选择锦州网站建设怎么去推广自己的店铺
  • 如何推广运营网站什么是交换链接
  • 百度网站建设大连做优化网站哪家好
  • vue做公司网站安卓系统优化软件