题目描述
输入一个字符串,求出该字符串包含的字符集合
输入描述:
每组数据输入一个字符串,字符串最大长度为100,且只包含字母,不可能为空串,区分大小写。
输出描述:
每组数据一行,按字符串原有的字符顺序,输出字符集合,即重复出现并靠后的字母不输出。
示例1
输入
abcqweracb
输出
abcqwer
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
string s;
while(cin>>s){
vector<bool> a(256,false);
for(int i=0;i<s.length();i++){
if(a[s[i]]==false){
a[s[i]]=true;
cout<<s[i];
}
}
cout<<endl;
}
return 0;
}
vector<bool> 将字母换算成ASCII码来比较,给定状态false和TRUE
之后的查找题可以用这种思路