题解 | #字符个数统计#
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
//使用hash表可以解决重复元素问题,hash实现可以使用数组,动态数组以及map映射
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
string s;
map<char, int> hash;
int count=0;
while (cin >> s) { // 注意 while 处理多个 case
for(int i=0;i<s.length();i++){
if (hash[s[i]]==0){
count++;
hash[s[i]]=1;
}
}
cout<<count<<endl;
}
}
// 64 位输出请用 printf("%lld")

查看5道真题和解析