单词统计
来源:互联网 发布:java程序员考证 编辑:程序博客网 时间:2024/06/05 17:37
单词统计
Des
给一个比较长的字符串,统计一共有多少个单词,并输出最短和最长的单词
Code
#include <iostream>#include <vector>#include <map>#include <sstream>using namespace std;int main() { string str1="Airmail, or standard mail?"; string str2="Do you have anything cheaper?"; string str=str1+" "+str2; map<string,int> m_arr; istringstream isstrm(str); string tmp; int cnt=0; int Max=-1; while(isstrm>>tmp){ cnt++; m_arr[tmp]=tmp.size(); if(Max<m_arr[tmp]){ Max=m_arr[tmp]; } } cout<<"共有单词:"<<cnt<<"最长的单词:"<<Max; return 0;}
0 0
- 统计单词
- 统计单词
- 单词统计
- 单词统计
- 单词统计
- 单词统计
- 统计单词
- 单词统计
- 统计单词
- 统计单词
- 单词统计
- 单词统计
- 单词统计
- 统计单词
- 统计单词
- 单词统计
- 统计单词
- 单词统计
- JamesMusic浅读--------8,音乐文件播放
- 搭建Dashgo运行环境
- JAVA多线程
- CSS布局奇淫巧计之-强大的负边距
- eclipse导入本地插件的方法
- 单词统计
- Python Flask Web 第五课 —— 包含导航条的程序基模板
- Animation.setFillAfter 是什么意思呢
- 斗鱼TV、熊猫TV移动端竞品分析
- 邻接表建图+深度遍历+判断连通性
- 编程命名规则
- scanf读取数值类型数据会在缓冲区中留下'\n'
- JDBC应用程序连接数据库--事务处理
- leetcode-28-Implement strStr()