VC++ 输入流迭代器
来源:互联网 发布:可口可乐表白软件 编辑:程序博客网 时间:2024/05/01 01:18
输入一些单词,中间使用空格分隔,最后统计每个单词出现的次数。
#include "stdafx.h"#include <iostream>#include <string>#include <tuple>#include <iomanip>#include <array>#include <map>#include <functional>using std::cin;using std::cout;using std::endl;using std::tuple;using std::string;using std::setw;using std::get;using std::pair;using std::map;int main(int argc,_TCHAR* argv[]){std::map<string,int> words;cout<<"Enter some text and press Enter followed by Ctrl+Z then Enter to end:"<<endl<<endl;std::istream_iterator<string> begin(cin); //Stream iteratorstd::istream_iterator<string> end;while(begin!=end)//Iterate over words in the streamwords[*begin++]++;//Increment and store a word countcout<<endl<<"Here a the world counts for the text you entered:"<<endl;const int wordsPerLine(4);int wordCount(0);cout<<std::setiosflags(std::ios::left);for(auto& word:words){cout<<std::setw(15)<<word.first<<" "<<std::setw(5)<<word.second;if(++wordCount % wordsPerLine ==0) cout<<endl;}cout<<endl;return 0;}
运行结果如下:
0 0
- VC++ 输入流迭代器
- VC模拟输入中文
- 【VC++】007字符输入
- VC模拟输入中文
- VC++结束输入
- VC++输入命令行参数
- VC 输入码注入源码:
- VC EDIT 输入限制操作
- VC中对输入设备的响应
- VC中对输入设备的响应
- 输入表察看程序(VC源码)
- VC中对输入设备的响应
- VC 制作IP地址输入框
- VC++ 编辑框只输入数字
- VC++ 实现CEdit编辑框输入小数!
- 用VC实现输入密码,显示**
- 用VC编写的SN快速输入工具
- 如何在VC++中用回车键切换输入焦点
- 第三章,设置按钮边框(Android)
- 动态链接库:相关1
- Java apache上传文件
- 25条提高iOS App性能的建议和技巧
- 笔记_网络02
- VC++ 输入流迭代器
- mysql备份恢复
- 设计模式04_抽象工厂模式
- 关于C#的Type.GetType血泪史
- poj 2407 Relatives 【容斥原理基础题】
- tar打包过滤某个文件及目录
- 后缀数组题目小结
- 2011年SAT数学成绩换算表介绍
- fullPage.js api 介绍