#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    vector<string> text;  //hold all word 
    string word;
    int max=0;
    
    cout<<"please input text :"<<endl;
        //read line......
    while(1)
    {
        cin>>word;
        if(max < word.size())
            max = word.size();
        text.push_back(word);
        
    if(cin.get()=='\n') break;
    }
//output.............
    int size=text.size();
    cout<<"longest  word : \n";
    for(int i=0; i<size; i++)
        if(text[i].size()==max)
            cout<<'\t'<<text[i]<<'\n';
    cout<<"lengh    : "<<max<<endl;
    system("pause");
    return 0;
}
把我前面的简化了一下




 
											






 
	    

 
	