ACM程序设计 -Z
来源:互联网 发布:ps淘宝详情页制作 编辑:程序博客网 时间:2024/05/16 04:57
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
思路:在循环里 定义一个 char数组 盛放一个单词,然后将那一个单词的 首字母 付给string 的变量a,同样的 把下一行的 首字母单词 付给 string 变量b,如果a==b,那么就 same
#if 1 // 26 #include<bits/stdc++.h>using namespace std;int main(){int n;cin>>n;for(int i=0;i<n;i++){int a,b;string ai,bi;cin>>a;char p[10];for(int j=0;j<a;j++){ cin>>p; ai=ai+p[0];}cin>>b;char pi[10];for(int jj=0;jj<b;jj++){cin>>pi;bi=bi+pi[0];}if (ai==bi) cout<<"SAME"<<endl;else cout<<"DIFFERENT"<<endl;}}#endif
- 《ACM程序设计》 Z题
- ACM程序设计 -Z
- ACM程序设计书上题目Z
- ACM程序设计题目 Problem Z-26
- 《ACM程序设计》书中题目―Z
- 《ACM程序设计》书中题目--problem z
- ACM程序设计 书中题目Z
- 《ACM程序设计》书中题目Z-26
- 《ACM程序设计》书中题目 Z
- 《ACM程序设计》书中题目 Z
- 《ACM程序设计》书中题目 Z
- acm程序设计书中题目z
- 《ACM程序设计》书中题目z
- 《ACM程序设计》书中题目Z(英文缩写)
- 《ACM程序设计》-Problem-Z-比较英文缩写是否相同
- Contest1376 - "师创杯"烟台大学第二届ACM程序设计精英赛复现Problem C: C-Z型变换
- 《ACM程序设计》书中题目Z 第二十六题 判断首字母缩写是相同
- ACM程序设计书中题目--z(两组字符串中单词的首字母是否相同)
- 老板会因为你拼死写代码而感谢你吗?
- 字典树
- Ubuntu 下 apt-get 更新源推荐
- QT 实现软件只能运行一个软件
- 递归算法之全排列
- ACM程序设计 -Z
- 网络基础知识
- post请求公共接口,参数为json串
- 微信公众号开发(3)---历史上的今天小实例
- 哈希算法(BDKR算法)
- Python分布式爬虫学习(一)
- 团体程序设计天梯赛-练习集 L2-014. 列车调度 解题报告
- acm书中题目 r-18
- 简述新笔记本安装ubuntu出现的各种问题解决方式