HDOJ/HDU 2564 词组缩写(单词缩写)
Problem Description
定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写。
比如,C语言里常用的EOF就是end of file的缩写。
Input
输入的第一行是一个整数T,表示一共有T组测试数据;
接下来有T行,每组测试数据占一行,每行有一个词组,每个词组由一个或多个单词组成;每组的单词个数不超过10个,每个单词有一个或多个大写或小写字母组成;
单词长度不超过10,由一个或多个空格分隔这些单词。
Output
请为每组测试数据输出规定的缩写,每组输出占一行。
Sample Input
1
end of file
Sample Output
EOF
大水题~ JAVA大发法好啊。
import java.util.Scanner;
/**
* @author 陈浩翔
* 2016-6-5
*/
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
sc.nextLine();
while(t-->0){
String str=sc.nextLine();
String[] s=str.split(" ");
String result="";
for(int i=0;i<s.length;i++){
if(s[i].length()>=1)
result+=s[i].charAt(0);
}
System.out.println(result.toUpperCase());
}
}
}
HDOJ/HDU 2564 词组缩写(单词缩写)的更多相关文章
- hdu 2564 词组缩写
Problem Description 定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写. 比如,C语言里常用的EOF就是end of file的缩写. Input 输入的第一行是一个整数T ...
- [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写
A string such as "word" contains the following abbreviations: ["word", "1or ...
- [LeetCode] Valid Word Abbreviation 验证单词缩写
Given a non-empty string s and an abbreviation abbr, return whether the string matches with the give ...
- [LeetCode] Unique Word Abbreviation 独特的单词缩写
An abbreviation of a word follows the form <first letter><number><last letter>. Be ...
- 单词缩写(abbr.cpp)每日一题
题目描述:YXY 发现好多计算机中的单词都是缩写,如 GDB,它是全称 Gnu DeBug 的缩写.但是,有时缩写对应的全称并不固定,如缩写 LINUX,可以理解为:(1)LINus's UniX ( ...
- [LeetCode] Word Abbreviation 单词缩写
Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations ...
- [Swift]LeetCode288. 唯一单词缩写 $ Unique Word Abbreviation
An abbreviation of a word follows the form <first letter><number><last letter>. Be ...
- [LeetCode] 527. Word Abbreviation 单词缩写
Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations ...
- [LeetCode] 288.Unique Word Abbreviation 独特的单词缩写
An abbreviation of a word follows the form <first letter><number><last letter>. Be ...
随机推荐
- scrapy shell 中文网站输出报错.记录.
UnicodeDecodeError: 'gbk' codec can't decode bytes in position 381-382: illegal multibyte sequence 上 ...
- 通过 OpenNI 建立 Kinect 3D Point Cloud
這篇還是算延續前一篇的<透過 OpneNI 合併 Kinect 深度以及彩色影像資料>.在可以透過 OpenNI 讀取到 Kinect 的深度.色彩資訊之後,其實就可以試著用這些資訊,來重 ...
- 下载youku视频(python3)
https://github.com/chenfengyuan/download-youku-video 用tornado写的下载脚本, 从flvcd.com得到下载地址. 因为我这边连youku的速 ...
- erlang 编程指南 第三章-顺序编程 课后练习
1. sum(3) => 6; sum(1,3) => 6; sum(6,6) => 6; sum(N) when is_integer(N) -> sum_acc(N,0); ...
- jekyll 的安装
静态网站生成器Jekyll 是一个简洁的.特别针对博客平台的 静态网站 生成器.它使用一个模板目录作为网站布局的基础框架,并在其上运行 Textile . Markdown 或 Liquid 标记语言 ...
- absolute之实现居中的三种方式
居中思想可以由很多方式实现,这篇文章采用absolute实现:由传统方式开始到absolute独立使用方式 方式一:传统方式,父容器relateive,子元素absolute,然后left:50%,再 ...
- php类的方法
方法就是在类中的function,很多时候我们分不清方法与函数有什么差别,在面向过程的程序设计中function叫做函数,在面向对象中function则被称之为方法. 同属性一样,类的方法也具有pub ...
- hadoop1中mapreduce原理详解
剖析Mapreduce作业运行机制:原理如下图: 原理图的解释的可以分为以下几个部分 1.客户端提交一个mapreduce的jar包给JobClient 2.JocClient通过RPC和JobTra ...
- C#中的反射 Assembly.Load() Assembly.LoadFrom()
一些关于C#反射的知识,估计也就最多达到使用API的程度,至于要深入了解,以现在的水平估计很难做到,所以下面此篇文章,以作为一个阶段的总结. 对于反射的总结,我想从以下几个方面展开,首先是反射程序集, ...
- HBase安装inAction
在安装Hbase之前,需要有hadoop的运行环境,关于hadoop的安装过程,请查看我之前的blog:hadoop安装笔记:或者另一个博主的超详细文章http://weixiaolu.iteye.c ...