#include "stdafx.h" #include "iostream" #include "sstream" #include "map" #include "string" #include "list" #include "vector" #include <cctype> using namespace std; int main() { string inputstr; string str; getline(cin,inputstr); string::size_type index=0; for (index = 0;index != inputstr.size();index++) { if(ispunct(inputstr[index])) { inputstr[index] = ‘ ‘; } } istringstream stream(inputstr); vector<string> svec; vector<string>::iterator isvec; bool find = false; while (stream>>str) { find = false; for (isvec = svec.begin(); isvec != svec.end();isvec++) { if (*isvec == str) { find = true; } } if (find == false) { svec.push_back(str); } } for (isvec = svec.begin(); isvec != svec.end();isvec++) cout<<*isvec<<" "; cout<<endl; }
去掉英文句子中重复出现的单词和标点符号,布布扣,bubuko.com
原文:http://blog.csdn.net/gaoxiangky/article/details/22783801