题解 | #统计字符#

统计字符

http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5

while (input = readline()) {
    const arr = input.split('');
    let eng = 0;
    let space = 0; // 32
    let num = 0; //48-57
    let other = 0;

    for (let item of arr) {
        let code = item.charCodeAt();
        if (code >= 65 && code <= 90 || code >=97 && code <=122) {
            eng++;
        } else if (code == 32) {
            space++;
        } else if (code >= 48 && code <= 57) {
            num++;
        } else {
            other++;
        }
    }

    print(eng);
    print(space);
    print(num);
    print(other);
}

全部评论

相关推荐

最喜欢秋天的火龙果很...:第一份工作一定要往大的去,工资低点没事。后面换工作会更好找,即使你去小公司,你也不可能不会换工作的。所以找大的去
点赞 评论 收藏
分享
LZHR:老哥你从投递简历测评完到一面中间隔了多久呀,我这边已经过了五天了仍显示简历筛选中是不是就是挂了
腾讯求职进展汇总
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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