7

您所在的位置:网站首页 一篇文章的英文单词 7

7

2024-07-15 06:10| 来源: 网络整理| 查看: 265

输入一篇英文文章,碰到"!!!!!"的时候停止,输出文章中出现的不重复单词的个数(注意:单词不区分大小写,如:The和the为一个单词)

输入格式:

一篇英文文章,以"!!!!!"结尾

输出格式:

不重复单词的个数

输入样例: Unmanned aerial vehicles have been adopted in the inspection of violations Procurators will file public interest litigations against perpetrators who will need to replant trees take down illegal buildings control pollution and compensate environment-related losses The Yellow River is the second longest river in China It originates in the northwestern province of Qinghai and runs through nine provinces and autonomous regions in western central north and eastern China !!!!! 输出样例: 55 代码: import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { HashMap hashMap = new HashMap(); Scanner cin = new Scanner(System.in); while (cin.hasNext()) { String str = cin.next(); if (str.equals("!!!!!")) break; str = str.toLowerCase(); hashMap.put(str, 1); } System.out.println(hashMap.size()); } }


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3