题目

When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows?

Input Specification:
Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in a 7×5 matrix of C’s and .'s. Then a sentence is given in a line, ended by a return. The sentence is formed by several words (no more than 10 continuous capital English letters each), and the words are separated by any characters other than capital English letters.

It is guaranteed that there is at least one word given.

Output Specification:
For each word, print the matrix form of each of its letters in a line, and the letters must be separated by exactly one column of space. There must be no extra space at the beginning or the end of the word.

Between two adjacent words, there must be a single empty line to separate them. There must be no extra line at the beginning or the end of the output.

Sample Input:
…C…
.C.C.
C…C
CCCCC
C…C
C…C
C…C
CCCC.
C…C
C…C
CCCC.
C…C
C…C
CCCC.
.CCC.
C…C
C…
C…
C…
C…C
.CCC.
CCCC.
C…C
C…C
C…C
C…C
C…C
CCCC.
CCCCC
C…
C…
CCCC.
C…
C…
CCCCC
CCCCC
C…
C…
CCCC.
C…
C…
C…
CCCC.
C…C
C…
C.CCC
C…C
C…C
CCCC.
C…C
C…C
C…C
CCCCC
C…C
C…C
C…C
CCCCC
…C…
…C…
…C…
…C…
…C…
CCCCC
CCCCC
…C
…C
…C
…C
C…C
.CCC.
C…C
C…C.
C.C…
CC…
C.C…
C…C.
C…C
C…
C…
C…
C…
C…
C…
CCCCC
C…C
C…C
CC.CC
C.C.C
C…C
C…C
C…C
C…C
C…C
CC…C
C.C.C
C…CC
C…C
C…C
.CCC.
C…C
C…C
C…C
C…C
C…C
.CCC.
CCCC.
C…C
C…C
CCCC.
C…
C…
C…
.CCC.
C…C
C…C
C…C
C.C.C
C…CC
.CCC.
CCCC.
C…C
CCCC.
CC…
C.C…
C…C.
C…C
.CCC.
C…C
C…
.CCC.
…C
C…C
.CCC.
CCCCC
…C…
…C…
…C…
…C…
…C…
…C…
C…C
C…C
C…C
C…C
C…C
C…C
.CCC.
C…C
C…C
C…C
C…C
C…C
.C.C.
…C…
C…C
C…C
C…C
C.C.C
CC.CC
C…C
C…C
C…C
C…C
.C.C.
…C…
.C.C.
C…C
C…C
C…C
C…C
.C.C.
…C…
…C…
…C…
…C…
CCCCC
…C
…C.
…C…
.C…
C…
CCCCC
HELLO~WORLD!

Sample Output:
C…C CCCCC C… C… .CCC.
C…C C… C… C… C…C
C…C C… C… C… C…C
CCCCC CCCC. C… C… C…C
C…C C… C… C… C…C
C…C C… C… C… C…C
C…C CCCCC CCCCC CCCCC .CCC.

C…C .CCC. CCCC. C… CCCC.
C…C C…C C…C C… C…C
C…C C…C CCCC. C… C…C
C.C.C C…C CC… C… C…C
CC.CC C…C C.C… C… C…C
C…C C…C C…C. C… C…C
C…C .CCC. C…C CCCCC CCCC.

解释

题目分为三步:

  1. 读入26个字母,我使用vector数组,每个大写字母对应7个string。
  2. 读入待打印的字符串,并进行拆分。拆分时需要注意两个地方(也是最后四分的地方):
      1) 开头非大写字母,那么就s.erase(s.begin());
      2) 两个有效的字符串之间的非大写字母数量大于1,那么就将t增加。
  3. 按照输出规则,每行输出的时候先将字符串相加,之后输出。两个有效的单词直接有空行输出。

正确代码

#include <iostream>
#include <cctype>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
vector<string> v[26], str;
int main(){string s;for(int i = 0; i < 26; i++){for(int j = 0; j < 7; j++){getline(cin, s);v[i].push_back(s);}}getline(cin, s);if(s == "")return 0; else{int pos = 0, t = 0;while(!isupper(s[0])) s.erase(s.begin());while(t < s.length()){while(isupper(s[t])) t++;str.push_back(s.substr(pos, t - pos));while(!isupper(s[t])) t++;pos = t ;}for(int l = 0; l < str.size(); l++){if(l != 0) cout << endl;for(int j = 0; j < 7; j++){string temp;for(int i = 0; i < str[l].length(); i++){if(i != 0) temp += " ";temp += v[str[l][i] - 'A'][j];}cout << temp << endl;}}}return 0;
}

2019年12月PAT甲级 第一题 Good in C(1164)题解相关推荐

  1. 2019年12月PAT甲级满分备考经验

    PAT甲级满分备考经验 答题过程 备考经验 答题过程   总得来说,我觉得我幸运,碰上了一次PAT甲级题目相当简单(1085中有190人满分),最终提前一小时交卷,实时排名为35.   我按照1 2 ...

  2. 2019年12月PAT甲级 第三题 Summit(1166)题解

    题目 A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summ ...

  3. 12月5日计算机考试浙江卷英语答案,英语b级试卷?2019年12月b级真题试卷。

    大学英语应用考试B级是什么? 英语B级考试过关技巧简介英语B级考试过关技巧介绍:[1听力](1--15小题)分数是占15%.在这里我们也应该用时15分钟.一般在这里的听力都是很容易的,(跟初. 英语b ...

  4. 【C++题解集合】PAT甲级真题(包含所有类型题解)

    ✍个人博客:https://blog.csdn.net/Newin2020?spm=1011.2415.3001.5343

  5. CKA真题 :2019年12月英文原题和分值

    所有命令都验证过,有更好的方式,欢迎留言~~~ CKA 习题和真题汇总 CKA考试经验:报考和考纲 CKA :2019年12月英文原题和分值 CKA考试习题:K8S基础概念--API 对象 CKA考试 ...

  6. 电子学会 2019年12月 青少年软件编程Python编程等级考试一级真题解析(选择题+判断题)

    青少年编程Python编程等级考试一级真题解析(选择题+判断题)2019年12月 一.选择题(共30题,共60分) 假设a=20,b=3,那么a or b的结果是() A. 20 B. 0 C. 1 ...

  7. 英语四级真题作文 计算机,2019年12月英语四级写作范文:电脑

    2019年12月英语四级考试即将开始,新东方在线小编整理了2019年12月英语四级写作范文,供参考. 让我们在电脑普及的今天,谈一谈电脑给我们带来了什么. 参考例文一: With the rapid ...

  8. wps两列数据分别作为xy轴_一图胜千字:科研论文插图/数据处理和图表制作学习会(2019年12月2729日 上海)...

    我是吸铁石,无论你多强大,只要你离我近,就会被磁化 放射技师考试资料独家整理历年真题.考点分析.名师讲解.影像资讯. 执业技师资格考试在路上,放射技师之路,你我同行. (全文共计1485字,预计阅读时 ...

  9. 2019年12月前端面经及总结(西安,杭州)

    2019年12月前端面经及总结(西安,杭州) 我的github主页:https://github.com/dashnowords 我的新书上架啦,3天即登京东计算机编程语言类排行榜Top1!!!精选3 ...

最新文章

  1. 企业架构 - 组织角色和技能
  2. python【蓝桥杯vip练习题库】BASIC-20 数的读法
  3. 女孩子学电脑进入IT行业有什么优势?
  4. 关于你不知道的特征归一化/标准化
  5. php数组函数及用法,php数组函数 in_array 的用法及注意事项
  6. 003.XE3包含了TPerlRegEx的单元
  7. PaddleHub教程合集
  8. 【产品体验】echo回声
  9. [转]netstat 输出内容详解,TCP链接握手对应state
  10. java假设模拟请求重新启动路由器(网络爬虫经常使用),还有java怎样下载图片
  11. 2016 ICPC 大连网络赛 部分题解
  12. [Elasticsearch2.x] 多字段搜索 (二) - 最佳字段查询及其调优 译
  13. matlab:快速傅里叶(反)变换 FFTIFFT
  14. Ryu学习总结(持续更新)
  15. 开始做公众号的一些方法技巧总结
  16. java int的取值范围为什么负数比正数多1
  17. mac部署rabbitmq流程与异常总结
  18. 2018广告屏蔽软件
  19. vue项目将页面生成pdf
  20. 微信H5页面禁止分享朋友和复制链接

热门文章

  1. 被称为“眼黄金”的叶黄素究竟是什么?叶黄素则能过滤蓝光
  2. EN 13163-2012 建筑保温产品,工厂生产发泡聚苯乙烯(EPS)产品.规范
  3. Java实现WinPcap+Wireshark数据抓包模拟联通客户端签到功能
  4. 读书笔记--推荐系统实践 第一章
  5. 零基础语法入门第第二十三讲 动词的用法总结
  6. 【转载】纳兰性德的诗词全集
  7. VLC在web系统中应用(x-vlc-plugin 即如何把VLC嵌入HTML中)第一篇
  8. c语言是流式,C语言中的文件又被称为流式文件。
  9. CSDN 写博客 word文档复制粘贴 图片粘贴 加载失败问题解决
  10. Worthington弹性蛋白酶的应用和相关研究