每组数据输入一个字符串,字符串最大长度为100,且只包含字母,不可能为空串,区分大小写。

// ConsoleApplication12.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
// ConsoleApplication12.cpp : 定义控制台应用程序的入口点。
//

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

void print(vector<char> vec)
{
	for (int i = 0;i < vec.size();++i)
	{
//		cout << vec[i] << " ";
		cout << vec[i] ;
	}

}
int main()
{
	vector<char> cVec;
	string str;
	cin >> str;
	string result=str[0]+"";
	for (int i = 0;i < str.size();++i)
	{
		char ch = str[i];
		if (find(cVec.begin(), cVec.end(), ch) == cVec.end()) //没有找到
		{
			cVec.push_back(ch);
		}
		
	}

	for (int i = 0;i < cVec.size();++i)
	{
		//		cout << vec[i] << " ";
		cout << cVec[i];
	}

//	cout << "cVec:";
//	print(cVec);

	return 0;
}

//注意:遇到中循环删除指针的问题,可以倒着删除
posted @ 2017-02-22 17:05  wdan2016  阅读(1440)  评论(0编辑  收藏  举报