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; }
查看全文
相关阅读:
vector常规用法(leedcode)
creaor小游戏数据表配置引发的相关问题
cocos2dx conversion to dalvik format failed
Java中如何实现列表对象(List)的灵活查找?/java中Listgen根据某个元素获取对象
MySql忘记root用户密码
命令行模式下备份和恢复mysql数据库
mysql开启日志
Python操作Excel文件
Python操作Json文件
Python操作xml文件
原文地址:https://www.cnblogs.com/dyufei/p/2573901.html
最新文章
pytest入门与基础用法
Linux和Windows下运行.sh文件
Windows通过端口查找进程并杀死进程
Python SHA1、MD5加密
python3-网站路径扫描
数据库类型判断方法
Weblogic_CVE-2018-2628
Weblogic_CVE-2020-14882/14883
JAVA单维数组与多维数组编程
static语句块
热门文章
第一个JAVA程序
NPOI 实践中遇到的一些情况
安卓系统自带样式
Cordova Phonegap
android webview和js的交互
web app(h5)、 源生app、混合app
消息提醒 BadgeView框架
贪吃蛇大作业相关
ostream用法
双指针验证回文串
Copyright © 2011-2022 走看看