首页 > 其他 > 详细

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

时间:2014-04-02 13:11:49      阅读:615      评论:0      收藏:0      [点我收藏+]
#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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!