运用标准库unique算法出错,得不到正确值

使用标准库unique算法出错,得不到正确值

/*编写程序统计长度不小于 4 的单词,并输出输入序列中不重复的单词。
在程序源文件上运行和测试你自己编写的程序。*/

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

bool isShorter(const string &str1,const string &str2)
{
return str1.size()<str2.size();
}

bool DY4(const string &str)
{
return str.size()>=4;
}

int main()
{
vector<string> words;
string str;
cout<<"输入一批单词:\n";
while(cin>>str)
words.push_back(str);

sort(words.begin(),words.end());
vector<string>::iterator it=unique(words.begin(),words.end());//调试显示这儿it没有值
words.erase(it,words.end());//因此这儿删除不了元素

stable_sort(words.begin(),words.end(),isShorter);
vector<string>::size_type n=count_if(words.begin(),words.end(),DY4);
cout<<"长度不小于4的单词有"<<n<<"个,它们是:"<<endl;
for(vector<string>::size_type i=0;i!=words.size();++i)
cout<<words[i]<<" ";
cout<<endl;

system("pause");
return 0;
}


运行截图:
运用标准库unique算法出错,得不到正确值
请大神指点。
------解决方案--------------------
引用:
C/C++ code??1234567891011121314151617181920212223242526272829303132333435363738394041/*编写程序统计长度不小于 4 的单词,并输出输入序列中不重复的单词。在程序源文件上运行和测试你自己编写的程序。*/ #include<iostream>#include<algorithm>#inclu……


你都没输入重复的元素啊

------解决方案--------------------
是你这里错了吧
for(vector<string>::size_type i=0;i!=words.size();++i) 
        cout<<words[i]<<" "; 
你并没有从words中删除掉不符合条件的item项