题解 | #字符个数统计#

字符个数统计

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();
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 12:05
点赞 评论 收藏
分享
05-27 14:57
西北大学 golang
强大的社畜在走神:27届真不用急,可以搞点项目、竞赛再沉淀沉淀,我大二的时候还在天天打游戏呢
投递华为等公司10个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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