文章
16
粉丝
0
获赞
41
访问
1.4k
#include<bits/stdc++.h>
using namespace std;
map<string, int> m;
bool cmp(string a,string b){
int count_a = m[a];
int count_b = m[b];
if(count_a != count_b)return count_a > count_b;//次数多的排在前面
else return a < b;//次数一样按字典序排序
}
int main(){
string s;
getline(cin,s);
vector<string> v;
string news = "";
for(int i=0;i<s.size();i++){
s[i] = tolower(s[i]);
if(isalpha(s[i]))news += s[i];//如果是字母就拼接成字符串
else {//遇见空格或者句号或者其他字符,非字母
if(news!=""){//如果此时已有拼接成的单词
if(m.find(news) == m.end()){//如果map中没有...
登录后发布评论
暂无评论,来抢沙发