zoukankan
html css js c++ java
c++ 字典排序 并统计字符串个数
#include <vector> #include <string> #include <algorithm> #include <iostream> #include <iterator> #include <map> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { vector<string> vec; vec.push_back("This"); vec.push_back("is"); vec.push_back("a"); vec.push_back("key"); vec.push_back("this"); vec.push_back("key"); vec.push_back("A"); vec.push_back("Thas"); vec.push_back("kEy"); map<string,int> words; vector<string>::iterator it = vec.begin(); for(it; it != vec.end(); ++it) { if(words.find(*it) != words.end() ) { int i = words[*it]; ++i; words[*it] = i; } else { words.insert(map<string,int>::value_type(*it,1)); } } map<string,int>::iterator mapit = words.begin(); for(mapit;mapit != words.end();++mapit) { cout<< mapit->first<<" "<<mapit->second<<endl; } return 0; }
查看全文
相关阅读:
面向对象进阶----->反射 getattr 和hasattr方法
封装和 property方法
C/S与B/S区别
BIO、NIO和AIO
ArrayList、Vector、LinkedList的区别
AOP代理模式
Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类,是否可以implements(实 现)interface(接口
Spring常见面试题及答案解析
数据库优化
事物的理解
原文地址:https://www.cnblogs.com/dyufei/p/2573901.html
最新文章
前端pdf 大全
npm
yarn 不要一起用 npm
sklearn的常用函数以及参数
关于sklearn,监督学习几种模型的对比
如何使用python查看视频的长度
使用sklearn做各种回归
python的加密操作
你知道怎么将自己写的模块上传到pypi吗?
你知道怎么用Python生成二维码、解析二维码吗?
热门文章
如何使用python下载网站上的视频
python--websocket数据解析
python实现websocket
re模块练习
异常处理
os 模块 模块与包的初始
time random sys 模块
configparser logging collections 模块
面向对象进阶------>模块 json pickle hashlib
面向对象进阶------>内置函数 str repr new call 方法
Copyright © 2011-2022 走看看