去掉英文句子中重复出现的单词和标点符号

#include "stdafx.h"
#include "iostream"
#include "sstream"
#include "map"
#include "string"
#include "list"
#include "vector"
#include 
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 svec;
	vector::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<


 

你可能感兴趣的:(C语言编程)