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());
        }
    }
}
时间: 2024-10-12 15:21:59

HDOJ/HDU 2564 词组缩写(单词缩写)的相关文章

HDU 2564 词组缩写

词组缩写 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14487    Accepted Submission(s): 4705 Problem Description 定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写.比如,C语言里常用的EOF就是end of file的缩写. Input 输入的第一行是一个整数T,表示一

单词缩写(abbr.cpp)每日一题

题目描述:YXY 发现好多计算机中的单词都是缩写,如 GDB,它是全称 Gnu DeBug 的缩写.但是,有时缩写对应的全称并不固定,如缩写 LINUX,可以理解为:(1)LINus's UniX (2)LINUs's miniX (3)Linux Is Not UniX现在 YXY 给出一个单词缩写,以及一个固定的全称(由若干个单词组成,用空格分隔).全称中可能会有无效的单词,需要忽略掉,一个合法缩写要求每个有效的单词中至少有一个字符出现在缩写中,缩写必须按顺序出现在全称中.对于给定的缩写和一

[LeetCode] Valid Word Abbreviation 验证单词缩写

Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains only the following valid abbreviations: ["word", "1ord", "w1rd", &

[LeetCode] 288.Unique Word Abbreviation 独特的单词缩写

An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations: a) it --> it (no abbreviation) 1 b) d|o|g --> d1g 1 1 1 1---5----0----5--8 c) i|nternationalizatio|n --&

[LeetCode] 527. Word Abbreviation 单词缩写

Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below. Begin with the first character and then the number of characters abbreviated, which followed by the last charact

HDOJ/HDU 2140 Michael Scofield&#39;s letter(字符转换~)

Problem Description I believe many people are the fans of prison break. How clever Michael is!! In order that the message won't be found by FBI easily, he usually send code letters to Sara by a paper crane. Hence, the paper crane is Michael in the he

HDOJ/HDU 1161 Eddy&#39;s mistakes(大写字母转换成小写字母)

Problem Description Eddy usually writes articles ,but he likes mixing the English letter uses, for example "computer science" is written frequently "coMpUtEr scIeNce" by him, this mistakes lets Eddy's English teacher be extremely disco

HDOJ/HDU 1250 Hat&#39;s Fibonacci(大数~斐波拉契)

Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4) Your task is to take

hdu acm 2082 找单词

找单词 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3722    Accepted Submission(s): 2663 Problem Description 假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于给定的字母,可以找到