题解 | #字符个数统计#
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
// HJ10 字符个数统计.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include<bits/stdc++.h> using namespace std; class Solution { public: int Sum_char(string& s) { sort(s.begin(), s.end()); s.erase(unique(s.begin(), s.end()), s.end()); return s.size(); } }; int main() { Solution a; string s; int b; while (getline(cin, s)) { b=a.Sum_char(s); cout << b << endl; } return 0; }