题解 | #字符个数统计#

字符个数统计

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

#include <array>
#include <iostream>
#include <numeric>
#include <string>
using namespace std;

int main() {
    int a, b;
    array<int, 128> list={0};
    string s;
    getline(cin, s);
    // cout << s << endl;

    for(auto ch:s){
        if (list[(int)ch] == 0) {
            list[(int)ch]=1;
        }
    }
    cout<<accumulate(list.begin(), list.end(), 0);
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

将不会再购买联想产品
Data_Seven:让他发一个拯救者过来 拯救一下你
投递联想等公司10个岗位
点赞 评论 收藏
分享
头像
08-22 10:55
已编辑
门头沟学院 数据仓库
码农索隆:好一个无限读档
投递快手等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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