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 ...
随机推荐
- ZOJ 1025 Wooden Sticks(快排+贪心)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=25 题目大意:机器运送n个木条,每个木条有一个长度和重量.运送第一根木 ...
- 263. Ugly Number(C++)
263. Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are ...
- UIView-图层方法
// // ViewController.m // UIView-图层概念 // // Created by wangtouwang on 15/5/5. // Copyright (c) 2015年 ...
- 多语言文本资源的访问(Windows:ini)
目标 本文要讨论对于开发多语言界面程序所需要解决的一个问题,即文本资源组织及访问的方法. 本文主要以Windows平台下讨论具现并提供处理代码. Windows方案 Windows下界面开发,除Dir ...
- samba和squid 安装
一. samba配置1. 什么是sambaSamba服务类似于windows上的共享功能,可以实现在Linux上共享文件,windows上访问,当然在Linux上也可以访问到.是一种在局域网上共享文件 ...
- 使用Yii框架中遇到的三个问题
以下由我们在信易网络公司开发项目的时候终结出的一些经验 使用Yii框架中遇到的三个问题 1.main.php文件中欲引入全局变量的问题 还原一下此问题:在Yii框架中,main.php一般会作为整个应 ...
- 【javascript 变量和作用域】
今天学习了javascript 的变量和作用域的基本知识,对于以前在开发中遇到的一些不懂的小问题也有了系统的认识,收获还是比较多的. [基本类型和引用类型] ECMAScript 变量可能包含两种不同 ...
- mongodb篇二:mongodb克隆远程数据库,去重查询的命令及对应java语句
http://blog.csdn.net/qkxh320/article/details/16115671 1.首先操作mongodb最基本命令:: show databases; ...
- __construct()和__initialize()
ThinkPHP中的__initialize()和类的构造函数__construct()网上有很多关于__initialize()的说法和用法,总感觉不对头,所以自己测试了一下.将结果和大家分享.不对 ...
- linux服务器监控流量sh脚本
服务器可能经常遇到服务器出带宽跑满,不知如何查询被哪个进程占用的情况,有一款开源的英文软件iftop功能比较强大可以查询相关信息,可能刚接触linux系统的朋友不太会使用,在此写了一个功能比较简单无需 ...