#include <iostream> #include <set> #include <algorithm> using namespace std; int main() { string str; cin>>str; set<char> a; for(int i=0;i<str.length();i++) a.insert(str[i]); cout<<a.size(); return 0; }
由题目意思就是求不重复的元素有多少个,直接用set存,进行去重,最后输出大小,即可。参与链接
#include <iostream> #include <set> #include <algorithm> using namespace std; int main() { string str; cin>>str; set<char> a; for(int i=0;i<str.length();i++) a.insert(str[i]); cout<<a.size(); return 0; }
由题目意思就是求不重复的元素有多少个,直接用set存,进行去重,最后输出大小,即可。参与链接