题目描述

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 insensitively) 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.

输入描述

The first line of the input is a positive integer T. T is the number of test cases followed. Each test case contains a string S with its length no greater than 100, representing the sequence of words to be abbreviated. The words consist of only alphabetic letter. There is only one space between the words, and there is no leading or trailing spaces in the string.

输出描述

For each test case, output the abbreviation of S.

样例输入

5
netease
The Lord of the Rings
North Eastern University at Qinhuangdao
Institute of Electrical and Electronics Engineers
Association for Computing Machinery

样例输出
N
LR
NEUQ
IEEE
ACM

import java.util.Scanner;public class Main {public static void main(String args[]) {Scanner se=new Scanner(System.in);int n=Integer.parseInt(se.nextLine());for(int i=0;i<n;i++) {String s=se.nextLine();String str[]=s.split("\\s+");String a="";for(int j=0;j<str.length;j++) {str[j]=str[j].toUpperCase();if(str[j].length()>2 & !str[j].equals("AND")& !str[j].equals("THE")& !str[j].equals("FOR")) {String ae=String.valueOf(str[j].charAt(0));a=a.concat(ae);}}System.out.println(a);}}
}

Abbreviation----Java实现相关推荐

  1. java类的注释模板_IDEA添加Java类注释模版的方法

    本文介绍了idea添加java类注释模版的方法,分享给大家,具体如下: idea版本:intellij idea 2017.2.5 x64 eclipse能在类上方输入/**,回车添加类注释模版,但i ...

  2. 常惠琢 201771010102《面向对象程序设计(java)》第七周学习总结

    实验七 继承附加实验 实验时间 2018-10-11 1.实验目的与要求 (1)进一步理解4个成员访问权限修饰符的用途: (2)掌握Object类的常用API用法: (3)掌握ArrayList类用法 ...

  3. Java 8 开发的 4 大技巧

    欢迎关注方志朋的博客,回复"666"获面试宝典 Java 开发过程经常需要编写有固定格式的代码,例如说声明一个私有变量,logger或者bean等等.对于这种小范围的代码生成,我们 ...

  4. Java编程中,有哪些好的习惯从一开始就值得坚持?

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 来源:https://urlify.cn/ZFfYva 1. 规范 ...

  5. 201771010126.王燕《面向对象程序设计(Java)》第六周学习总结

    实验六 继承定义与使用 实验时间 2018-9-28 1.实验目的与要求 (1) 理解继承的定义: 继承就是用已有类来构建新类的一种机制,当你继承了一个类时,就继承了这个类的方法和字段,同时你也可以在 ...

  6. java类功能说明注释添加,IDEA添加Java类注释模版的方法

    本文介绍了idea添加java类注释模版的方法,分享给大家,具体如下: idea版本:intellij idea 2017.2.5 x64 eclipse能在类上方输入/**,回车添加类注释模版,但i ...

  7. java bs架构书_基于BS架构的图书借阅管理模块的分析与设计(JSP+MySQL)(新品)

    基于BS架构的图书借阅管理模块的分析与设计(JSP+MySQL)(新品) 来源:2BYSJ.cn 资料编号:2SJ295500 资料等级:★★★★★ %D7%CA%C1%CF%B1%E0%BA%C5% ...

  8. java 枚举类 enum

    有时候,变量的取值,只在一个有限的集合内,例如,销售的复追的或这披萨饼中有小.中.大.超大这四种尺寸.针对种种情况可自定义枚举类型.枚举类型包括有限个命名的值,例如: enum Size {SMALL ...

  9. Python JAVA Solutions for Leetcode

    Python & JAVA Solutions for Leetcode (inspired by haoel's leetcode) Remember solutions are only ...

  10. Java-Class-C:java.util.Date

    ylbtech-Java-Class-C:java.util.Date Module java.base Package java.util Class Date java.lang.Object j ...

最新文章

  1. dev c++自动排版_再也不头疼文字排版了
  2. [云炬python3玩转机器学习笔记] 3-12 数据加载和简单的数据探索
  3. 用c语言编程参赛信息查询,确定参赛者名单(C语言实现)
  4. 匿名提问:rm -rf了怎么办?
  5. Mac电脑问题:磁盘读写NTFS怎么不行?
  6. java监控gc线程_Java应用性能监控系统,使用JMX实现,实现了类加载监控、内存监控、线程监控、GC监控...
  7. MINIDUMP_TYPE详解
  8. 手机抢答器正在替代传统抢答器
  9. 大学女生全面超男生,一个标志性事件
  10. poj2387(Dijkstra)
  11. RN vivo访问相册失败 warning : User cancelled image selection
  12. 【美】纳西姆·尼古拉斯·塔勒布 - 随机生存的智慧(2013年7月16日)
  13. Photoshop滤镜巧制超级美女插画效果(转)
  14. 5分钟带你看完 WWDC 2018
  15. Android学习之管理Activity的生命周期
  16. 个人微信小程序可以使用微信支付的解决方法
  17. 计算机如何与电视屏幕连接,电脑如何与电视机连接
  18. [笔记分享] [Power] MSM8x60 Power Management study report
  19. 大公司的PHP面试题
  20. com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.zha

热门文章

  1. Redis Master/Salve Replication(主从复制模式)
  2. TCR历史论文多久能发表?
  3. 胃肠道微生物与癌症有关
  4. 2015年第四届C/C++ A组蓝桥杯省赛真题
  5. 飞鹅WiFi打印机配置,php调用接口
  6. 千峰Java教程:071. 数据结构之链表①
  7. css3动画 魔方 无限滚动
  8. 机器学习-朴素贝叶斯(高斯、多项式、伯努利)
  9. 引爆寒假招生——圣诞节活动方案大放送
  10. BI是什么意思?在企业应用中有哪些好处?