简洁代码
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main()
{
string str;
getline(cin, str);
set<char> s;
for (int i = 0; i < str.size(); i++) {
if (!(str[i] >= 0 && str[i] <= 127)) { // 检验[0,127]边界
continue;
}
if (str[i] == '\n') { // 检验换行符
break;
}
s.emplace(str[i]);
}
cout << s.size();
}
京公网安备 11010502036488号