Problem Z-26
来源:互联网 发布:英汉双语阅读软件 编辑:程序博客网 时间:2024/05/20 23:06
Description
When a Little White meets another Little White:
Little White A: (Surprised) !
Little White B: ?
Little White A: You Little White know "SHDC"? So unbelievable!
Little White B: You are little white! Little white is you! What is "SHDC" you are talking about?
Little White A: Wait... I mean "Super Hard-disc Drive Cooler".
Little White B: I mean "Spade Heart Diamond Club"... Duck talks with chicken -_-//
Little White A: Duck... chicken... faint!
------quote from qmd of Spade6 in CC98 forum.
Sometimes, we write the abbreviation of a name. For example IBM is the abbreviation for International Business Machines. A name usually consists of one or more words. A word begins with a capital letter ('A' - 'Z') and followed by zero or more lower-case letters ('a' - 'z'). The abbreviation for a name is the word that consists of all the first letters of the words.
Now, you are given two names and asked to decide whether their abbreviations are the same.
Input
Standard input will contain multiple test cases. The first line of the input is a single integerT which is the number of test cases. And it will be followed by T consecutive test cases.
There are four lines for each case.
The first line contains an integer N (1 <= N <= 5), indicating the number of words in the first name.
The second line shows the first name.
The third line contains an integer M (1 <= M <= 5), indicating the number of words in the second name.
The fourth line shows the second name.
Each name consists of several words separated by space. Length for every word is less than 10. The first letter for each word is always capital and the rest ones are lower-case.
Output
Results should be directed to standard output. The output of each test case should be a single line. If two names' abbreviations are the same, output "SAME", otherwise output "DIFFERENT".
Sample Input
34Super Harddisc Drive Cooler4Spade Heart Diamond Club3Shen Guang Hao3Shuai Ge Hao3Cai Piao Ge4C P C S
Sample Output
SAMESAMEDIFFERENT
题目要求我们经常缩写,一个名字通常包含多个单词。一个单词以一个大写字母大头(“A”~“Z”),后面不跟或跟多个小写字母(“a”~“z”)。缩写是由每个字母的首字母组成。现在,给出两个名字,要求你说出这两个名字的缩写是否相同。解题思路:
读取数据,每读到一个单词取出它的首字母,组成缩写词,读取下一个名字,以同样的标准组成缩写词,比较两个缩写词是否相同。解题代码:#include<iostream>#include<string>using namespace std;int main(){ string f,ff,fff; int t,n,m,i,j; cin>>t; for(i=0;i<t;i++) { cin>>n; for(j=0;j<n;j++) { cin>>f; ff=ff+f[0]; } cin>>m; for(j=0;j<m;j++) { cin>>f; fff=fff+f[0]; } if(ff.compare(fff)==0) cout<<"SAME"<<endl; else cout<<"DIFFERENT"<<endl; ff=" "; fff=" "; } return 0;}
- Problem Z-26
- ACM程序设计题目 Problem Z-26
- ZOJ 1457 Prime Ring Problem @Z
- IE 6 & IE 7 Z-Index Problem
- 《ACM程序设计》书中题目--problem z
- Problem D: 求(x-y+z)*2
- Problem D: 求(x-y+z)*2
- 《ACM程序设计》-Problem-Z-比较英文缩写是否相同
- ACM习题Z-26
- z
- z
- Z
- Z
- Z
- Z
- Z
- Z
- Z-26 Two names' abbreviations
- RecyclerView复用ViewPager出现的问题
- 顺时针打印矩阵
- 1002. A+B for Polynomials
- 让网络请求简单点——Volley框架(下)
- 多线程环境下处理未捕获的异常
- Problem Z-26
- codevs 1135 选择客栈 2011年NOIP全国联赛提高组
- 详解SQL 注入、XSS 攻击、CSRF 攻击
- 1009. Triple Inversions (35)
- 你必须『收藏』的Github技巧
- Http(超文本传输协议)那点儿破事
- VS2013配置Winpcap开发环境
- 生成排列
- 华为oj初级 统计大写字母个数