题解 | #字符个数统计#
字符个数统计
http://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
string str1;
cin >> str1;
int n = str1.length()-1;
sort(str1.begin(), str1.end()); //将字符串排序,如果后一个跟前一个不相同就加一
int count=1;
for(int i=1; i<=n; i++){
if(str1[i]!=str1[i-1]){
count++;
}
}
cout<<count<<endl;
return 0;
}