题解 | #字符个数统计#
字符个数统计
http://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
非必要不用真hash,数组实现:
#include <iostream>
using namespace std;
int main()
{
string str;
int strset[505] = {0};
int cnt = 0;
cin >> str;
for(int i = 0; i < str.length(); i++) {
if(strset[static_cast<int>(str[i])] == 0) {
strset[static_cast<int>(str[i])] = 1;
cnt++;
}
}
cout << cnt << endl;
return 0;
}