As we know, we often use a short sequence of characters in place of some words with a very long name. For example, ACM is an abbreviation of “Association for Computing Machinery”. Now we are using an acronymic method to get the abbreviation. An acronym is generated from a long name by capitalizing the first letter of every word in the name and concatenating them together. There is an exception: some words are ignored when generating the abbreviation. These words( case insensitive) meet the following rules:

1. The common words “and”, “for”, and “the”.

2. The words with length less than 3, such as “a”, “of”, “to”. Your job is to get the abbreviation of a given string by using the acronymic method.

输入

Input starts with an integer T (T <= 100), denoting the number of test cases. Each case contains a line with several words seperated by space(s). The length of each line is less than 100. And you can assume that there is at least one available word for each case.

输出

For each case, print the abbreviation of the word.

样例输入

5

Online Judge

Association for Computer Machinery

Institute of Electrical and Electronics Engineers

The Lord of the Rings

netease

样例输出

OJ

ACM

IEEE

LR

N

import java.util.Scanner;

/**

*

* @author admin

*As we know, we often use a short sequence of characters in place of some words with

*a very long name. For example, ACM is an abbreviation of “Association for Computing

*Machinery”. Now we are using an acronymic method to get the abbreviation. An acronym

*is generated from a long name by capitalizing the first letter of every word in the

*name and concatenating them together. There is an exception: some words are ignored

*when generating the abbreviation. These words( case insensitive) meet the following rules:

*

*1. The common words “and”, “for”, and “the”.

*

*2. The words with length less than 3, such as “a”, “of”, “to”.

*Your job is to get the abbreviation of a given string by using the acronymic method.

*

*输入

*Input starts with an integer T (T <= 100), denoting the number of test cases.

*Each case contains a line with several words seperated by space(s). The length

*of each line is less than 100. And you can assume that there is at least one

*available word for each case.

*输出

*For each case, print the abbreviation of the word.

*实例:

*输入:

*5

*Online Judge

*Association for Computer Machinery

*Institute of Electrical and Electronics Engineers

*The Lord of the Rings

*netease

*输出:

*OJ

*ACM

*IEEE

*LR

*N

*/

public class Abbreviation {

public static void main(String[] args) {

Scanner input=new Scanner(System.in);

int num=Integer.valueOf(input.nextLine());

String[] strArr=new String[num];

for (int i = 0; i < strArr.length; i++) {

strArr[i]=input.nextLine();

}

input.close();

for (int i = 0; i < strArr.length; i++) {

computer(strArr[i]);

}

}

public static void computer(String str)

{

String[] word=str.split(" ");

String tempStr="";

for (int i = 0; i < word.length; i++) {

tempStr+=getWord(word[i]);

}

System.out.println(tempStr);

}

public static String getWord(String str)

{

if(str.length()<3||"and".equals(str)||"for".equals(str)||

"the".equals(str)||"And".equals(str)||"For".equals(str)||"The".equals(str))

{

return"";

}

return str.substring(0, 1).toUpperCase();

}

}

java起源英文_Abbreviation 英文词组缩写(来源:南阳理工大学ACM)java相关推荐

  1. JavaSE入门0之java起源与发展历程

    JavaSE入门0之java起源与发展历程 文章目录 JavaSE入门0之java起源与发展历程 前言 1.Java的起源 2.Java和互联网 3.java历史 4.java语言特点 5.java应 ...

  2. Java面试题目汇总/英文Java面试题(核心知识)

    一.面向对象的三个基本特征    2.方法重载和方法重写的概念和区别    3.接口和内部类.抽象类的特性    4.文件读写的基本类    **5.串行化的注意事项以及如何实现串行化    6.线程 ...

  3. java 英文字符 字节_3、在JAVA语言中,每个英文字符占 个字节,每个中文汉字占( )个字节。...

    [判断题]中心原子中的几个原子轨道杂化时,必形成数目相同的杂化轨道. [单选题]集合 用区间表示正确的是 ( ) [单选题]15.Java语言的类间的继承关系是 [单选题]8.编译Java Appli ...

  4. python使用matplotlib可视化、使用英文单次或者缩写指定使用的颜色、使用16进制的RGB字符串指定颜色、使用RGB或者RGBA数字元组指定颜色

    python使用matplotlib可视化.使用英文单次或者缩写指定使用的颜色.使用16进制的RGB字符串指定颜色.使用RGB或者RGBA数字元组指定颜色 目录

  5. 输入一行字符,用Java分别统计出其中英文字母、空格、数字和其他字符的个数。

    输入一行字符,用Java分别统计出其中英文字母.空格.数字和其他字符的个数. package p3;import java.util.*;public class floatlength {publi ...

  6. 集成沟通中的名词:DMZ 是英文“Demilitarized Zone”的缩写,中文名称为“隔离区”

    DMZ 是英文"Demilitarized Zone"的缩写,中文名称为"隔离区", 与军事区和信任区相对应,也称"非军事化区",是为了解决 ...

  7. Java国际化编程之中英文切换

    一.国际化编程的本质及原理分析 一套软件,多个语言包 Java是第一个设计成支持国际化的编程语言 重点在于如下两个类: java.util.ResourceBundle 用于加载一个语言_国家包 ja ...

  8. 关于java的参考文献英文_java英文参考文献

    programming problems, what about the other 20 percent-the "really hard stuff?" The most po ...

  9. HDU 2564 词组缩写

    词组缩写 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

最新文章

  1. Yii框架2.0的视图和widgets表单的使用
  2. linux授权文件夹给用户_一项一项教你测等保2.0——Linux访问控制
  3. 分析酸对酸性染料染羊毛染色性能的影响?举例说明酸性染料染羊毛时,如何选择合适的染浴pH值?并说明原因。
  4. 计算机网络学习笔记-1.2.3OSI参考模型(2)
  5. php 面相对象设计,PHP面向对象设计的规范
  6. NET 下数据库图片的存入与读取
  7. idea打开vue项目后报错ESLint: Expected space or tab after ‘//‘ in comment.(spaced-comment)
  8. 60-008-000-使用-命令
  9. java yield方法_Java中的yield方法
  10. python人狗大战游戏_6.5 人狗大战.py
  11. JavaScript-ES6新特性详解
  12. win7“您可能没有权限使用网络资源”的解决办法
  13. mysql触发器安全吗_猎八哥浅谈MYSQL触发器
  14. 无损批量合并视频 附工具
  15. 用MATLAB求解非线性微分方程
  16. 路由控制——ACL、IP-Prefix List
  17. 力扣908. 最小差值 I
  18. html 获取页面缩略图,html – 从Vimeo获取img缩略图?
  19. twitter客户端_使用Twitter进行客户推荐
  20. 数据结构(C语言版)——绪论

热门文章

  1. WPF 实现调用本机摄像头~
  2. Blazor系列终结!
  3. 基于事件驱动架构构建微服务第13部分:使用来自Apache KAFKA的事件并将投影流传输到ElasticSearch...
  4. 05Prism WPF 入门实战 - Navigation
  5. 再谈C#中的委托和事件
  6. .NET Core 服务在 ARM64 服务器中的部署
  7. 发布 .NET 5 带运行时单文件应用时优化文件体积的方法
  8. Magicodes.IE.AspNetCore之一行代码多格式导出
  9. OSI强调:SSPL并不是开源许可证
  10. 关于TensorFlow开发者证书,你想要的资源都在这里!