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; }
查看全文
相关阅读:
(转)STMFD和LDMFD指令个人理解分析
[原创] linux下的串口调试工具
详解Makefile 函数的语法与使用 (转)
sed命令详解(转)
[转]QT4解决中文乱码(tr的使用 | QTextCodec)
新型的按键扫描程序,仅三行程序(转)
VS2010旗舰版不能安装Silverlight4_Tools的解决方案
ASP.NET MVC3+EF4+Oracle入门实例(六)
一个ASP.NET文件下载类
项目管理实践【四】自动编译和发布网站【Using Visual Studio with Source Control System to build and publish website automatically】
原文地址:https://www.cnblogs.com/dyufei/p/2573901.html
最新文章
.NET 2.0新特性学习泛型
Linq学习笔记延迟操作符(投影操作符)
SQL Server 2008还原SQL Server 2000数据库文件
Json 序列化学习笔记(1)
Linq学习笔记延迟操作符(限定操作符)
C#委托学习笔记
【20110225】 Winfrom 窗体捕获键盘鼠标事件
LINQ体验(一) to SQL语句之对象标识和对象加载
LINQ体验(三)实现LINQ通用分页绑定方法
Aggregate 为字符串数组元素添加单引号 可用于SQL数据查询 in
热门文章
Winform 鼠标拖动窗体
LINQ体验(二)使用LINQ联合查询多表结果集的返回
修改数据库结构时,添加注释
LINQ体验(四)——LINQ to SQL语句之Select/Distinct和Count/Sum/Min/Max/Avg
LINQ 数据分组、统计实例
LINQ分组查询统计
QT界面(控件)相关设计的一些技巧总结(转)
[转载]ARM Linux内核启动过程
[原创]串口调试工具
c语言实现sin,cos,sqrt,pow函数
Copyright © 2011-2022 走看看