博客
关于我
c++ primer 5th 练习11.9自己编写的答案
阅读量:306 次
发布时间:2019-03-04

本文共 698 字,大约阅读时间需要 2 分钟。

#include 
#include
#include
#include
#include
#include
//stringstream对象需要包含头文件sstream#include
using namespace std;int main(){map
> word_linenumber;string words;int number = 0;string word;while(getline(cin,words)) { ++ number; stringstream in(words); while(in >> word) word_linenumber[word].push_back(number); }for(const auto & i : word_linenumber) { cout << i.first << ":"; for(auto j : i.second) cout << j << " "; cout << endl; } return 0;}

运行结果:

i am a goodboy and you are a good boytoo so you are a good boya:1 3 4 am:1 and:2 are:3 4 boy:2 3 5 good:1 3 5 i:1 so:4 too:4 you:2 4

总结:list也可以使用push_back()在末尾添加元素

转载地址:http://yfvq.baihongyu.com/

你可能感兴趣的文章
【JokerのZYNQ7020】LINUX_EMIO_LED。
查看>>
【JokerのZYNQ7020】LINUX_EMIO_BUTTON。
查看>>
vim匹配特定的行并删除
查看>>
读取excel文件错误
查看>>
傅里叶变换的初级理解三
查看>>
F1 score的意义
查看>>
python36+centos7离线安装tensorflow与talib的方法
查看>>
hdf5与hdfs的区别
查看>>
scala运行的方式
查看>>
tf.Session().as_default的作用
查看>>
isnull与isna的区别
查看>>
python自带超参调优包
查看>>
判断python模型是否安装的办法
查看>>
xgboost与gbdt的区别
查看>>
软件测试中使用coverage统计python代码的覆盖率
查看>>
从double到float的强制类型转换
查看>>
C++ 任意数据类型转为16进制输出
查看>>
PYTHON UDP只能接收本地报文,无法接收其他主机通过路由器发过来的报文
查看>>
QLabel控件功能示例
查看>>
vue项目中报/sockjs-node/info错误
查看>>