import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        String[] words = new String[20];
        System.out.println("请输入二十个单词:");
        Scanner put=new Scanner(System.in);
        int count1 = 0,count2 = 0,count3 = 0;
        int i = 0;
        for(int j = 0;j < words.length;j++) {
            words[j] = put.next();
        }
        do {
            if(words[i].charAt(0)=='w') {
                count1++;
            }
            if(words[i].contains("or")) {
                count2++;
            }
            if(words[i].length()==3) {
                count3++;
            }
            i++;
        }
        while(i<words.length);
        System.out.println("以字母w开头的单词数:"+count1);
        System.out.println("单词中含“or”字符串的单词数:"+count2);
        System.out.println("长度为 3 的单词数:"+count3);
    }
}

posted on 2022-11-22 14:47  wshidaboss  阅读(137)  评论(0编辑  收藏  举报