//编写程序读入一系列单词,并将它们存储在stack对象中
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main()
{
stack<string> sstack;
string str;
cout<<"Enter some words(Ctrl+Z to end):"<<endl;
while(cin>>str)
{
sstack.push(str);
}
return 0;
}
定义一个map对象,将单词与一个list对象关联起来,该list对象存储对应的单词可能出现的行号。
map< string, list<int> > wordLines;