那里错了???
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main()
{
string line1="We were her pride of 10 she named us --";
string line2="Benjamin, Phoenix, the prodigal";
string line3="and perspicacious pacific suzanne";
string sentence=line1+' '+line2+' '+line3;
cout <<sentence <<endl;
string::size_type pos=0, prev_pos=0;
typedef pair<short,string> track;
vector<track> words;
string word;
short len;
while((pos=sentence.find_first_of(' ',pos)) !=string::npos)
{
len=pos-prev_pos;
word=sentence.substr(prev_pos,len);
cout<<word<<endl;
words.push_back(make_pair(len,word));
prev_pos=++pos;
}
len = pos-prev_pos;
word=sentence.substr(prev_pos,len);
cout<<word<<endl;
words.push_back(make_pair(len,word));
int min =words[0].first;
int max=words[0].first;
int i=0;
for(i=0; i<words.size(); ++i)
{
if(min>words[i].first)
min=words[i].first;
if(max<words[i].first)
max=words[i].first;
}
cout<<"min \n";
for(i=0;i<words.size();++i)
{
if(min==words[i].first)
cout<<words[i].first<<" "<<words[i].second<<endl;
}
cout<<"max \n";
for(i=0;i<words.size(); ++i)
{
if(max==words[i].first)
cout<<words[i].first<<" "<<words[i].second<<endl;
}
return 0;
}