大学生程序设计竞赛(专业组)
Time Limit: 1 Sec Memory Limit: 128 MB
Description
对给定的英文短语写出它的缩写,比如我们经常看到的SB就是Safe Browsing的缩写。
Input
输入的第一行是一个整数T,表示一共有T组测试数据。 接下来有T行,每组测试数据占一行,每行有一个英文短语,每个英文短语由一个或多个单词组成;每组的单词个数不超过10个,每个单词有一个或多个大写或小写字母组成; 单词长度不超过10,由一个或多个空格分隔这些单词。
Output
请为每组测试数据输出规定的缩写,每组输出占一行。
Sample Input Copy
1 end of file
Sample Output Copy
EOF
Java代码:
import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()) { int N=sc.nextInt(); sc.nextLine(); while(N-->0) { String s=sc.nextLine(); StringBuffer sb=new StringBuffer(); String [] ss=s.split(" "); for(int i=0;i<ss.length;i++) { sb.append(ss[i].charAt(0)); } System.out.println(sb.toString().toUpperCase()); } } } }运行结果:
Language: Java Result: Accepted Time:118 ms Memory:10276 kb暂时不知道其他真确写法,可私或评
END
