题解 | #字符个数统计#
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { string str; getline(cin,str); vector<int> tongji(0); tongji.resize(128); for(int i=0;i<str.size();i++){ tongji[(int)str[i]] = 1; } cout<<count(tongji.begin(), tongji.end(), 1); } // 64 位输出请用 printf("%lld")
刷题进入状态了。熟练运用vector,algorithm和c++的迭代器特性求解。