题解 | #字符个数统计#

字符个数统计

https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50

简洁代码

#include <iostream>
#include <set>
#include <string>
using namespace std;
int main()
{
    string str;
    set<char> s;
    cin >> str;
    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();
}
全部评论

相关推荐

见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
05-20 13:59
门头沟学院 Java
米黑子米黑子:你这个成绩不争取下保研?
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务