题解 | #单词倒排#

统计字符

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

没什么好说的,今天刷了15道字符串,现在是凌晨两点。

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        int[] count = new int[4];
        for(char c : str.toCharArray()){
            if(c>='a'&&c<='z'||c>'A'&&c<'Z'){
                count[0]++;
            }
            else if(c == ' '){
                count[1]++;
            }
            else if(c>='0'&&c<='9'){
                count[2]++;
            }
            else{
                count[3]++;
            }
        }
        for(int i : count){
            System.out.println(i);
        }
    }
}
全部评论

相关推荐

牛客48826091...:哥们胸肌挺好看
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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